Method for encoding/decoding image signal and device therefor

ABSTRACT

An image decoding method according to the present invention may comprise the steps of: dividing a coding block into a first prediction unit and a second prediction unit; deriving a merge candidate list for the coding block; deriving first motion information for the first prediction unit and second motion information for the second prediction unit by means of the merge candidate list; and on the basis of the first motion information and the second motion information, acquiring a prediction sample within the coding block.

CROSS REFERENCE TO RELATED APPLICATION

This is a continuation of International Application No.PCT/KR2019/015200, filed on Nov. 8, 2019, and entitled “METHOD FORENCODING/DECODING IMAGE SIGNAL AND DEVICE THEREFOR”, which is based onand claims priorities of Korean Application No. 10-2018-0136249, filedon Nov. 8, 2018 and Korean Application No. 10-2018-0136306, filed onNov. 8, 2018. The disclosure of the above applications is herebyincorporated by reference in their entireties.

TECHNICAL FIELD

The present disclosure relates to a video signal encoding and decodingmethod and an apparatus therefor.

BACKGROUND

As display panels are getting bigger and bigger, video services offurther higher quality are required more and more. The biggest problemof high-definition video services is significant increase in datavolume, and to solve this problem, studies for improving the videocompression rate are actively conducted. As a representative example,the Motion Picture Experts Group (MPEG) and the Video Coding ExpertsGroup (VCEG) under the International TelecommunicationUnion-Telecommunication (ITU-T) have formed the Joint Collaborative Teamon Video Coding (JCT-VC) in 2009. The JCT-VC has proposed HighEfficiency Video Coding (HEVC), which is a video compression standardhaving a compression performance about twice as high as the compressionperformance of H.264/AVC, and it is approved as a standard on Jan. 25,2013. With rapid advancement in the high-definition video services,performance of the HEVC gradually reveals its limitations.

SUMMARY

An object of the present disclosure is to provide a method of applyingpartitioning to a coding block to obtain a plurality of predictionblocks in encoding/decoding a video signal, and an apparatus forperforming the method.

Another object of the present disclosure is to provide a method ofderiving motion information of each of a plurality of prediction blocks,in encoding/decoding a video signal.

Another object of the present disclosure is to provide a method ofderiving a merge candidate using an inter-region motion informationlist, in encoding/decoding a video signal.

The technical problems to be achieved in the present disclosure are notlimited to the technical problems mentioned above, and unmentioned otherproblems may be clearly understood by those skilled in the art from thefollowing description.

A method of decoding/encoding a video signal according to the presentdisclosure may include the steps of: applying partitioning to a codingblock to obtain a first prediction unit and a second prediction unit;deriving a merge candidate list for the coding block; deriving firstmotion information for the first prediction unit and second motioninformation for the second prediction unit using the merge candidatelist; and obtaining a prediction sample in the coding block based on thefirst motion information and the second motion information. At thispoint, whether or not to apply partitioning to the coding block isdetermined based on a size of the coding block, and the first motioninformation for the first prediction unit is derived from a first mergecandidate in the merge candidate list, and the second motion informationfor the second prediction unit is derived from a second merge candidatedifferent from the first merge candidate.

In the video signal encoding and decoding method according to thepresent disclosure, when at least one among a width and a height of thecoding block is greater than a threshold value, partitioning of thecoding block may not be not allowed.

In the video signal encoding and decoding method according to thepresent disclosure, the method may further include the step of decodingfirst index information for specifying the first merge candidate andsecond index information for specifying the second merge candidate froma bitstream, and when a value of the second index information is equalto or greater than a value of the first index information, the value ofthe second index information specifying the second merge candidate isobtained by adding 1 to the value of the first index informationspecifying the first merge candidate.

In the video signal encoding and decoding method according to thepresent disclosure, when the prediction sample is included in a boundaryregion between the first prediction unit and the second prediction unit,the prediction sample may be derived based on a weighted sum operationof a first prediction sample derived based on the first motioninformation and a second predicted sample derived based on the secondmotion information.

In the video signal encoding and decoding method according to thepresent disclosure, a first weighting value applied to the firstprediction sample may be determined based on an x-axis coordinate and ay-axis coordinate of the prediction sample.

In the video signal encoding and decoding method according to thepresent disclosure, a second weighting value applied to the secondprediction sample may be derived by subtracting the first weightingvalue from a constant value.

In the video signal encoding and decoding method according to thepresent disclosure, the maximum number of merge candidates that themerge candidate list may include may be determined based on whether thecoding block is partitioned into the first prediction unit and thesecond prediction unit.

Features briefly summarized above with respect to the present disclosureare merely exemplary aspects of the detailed description of the presentdisclosure that will be described below, and do not limit the scope ofthe present disclosure.

According to the present disclosure, inter prediction efficiency can beimproved by providing a method of applying partitioning to a codingblock to obtain a plurality of prediction blocks, and deriving motioninformation of each of the prediction blocks.

According to the present disclosure, inter prediction efficiency can beimproved by providing a method of deriving a merge candidate using aninter-region motion information list.

The effects that can be obtained from the present disclosure are notlimited to the effects mentioned above, and unmentioned other effectsmay be clearly understood by those skilled in the art from the followingdescription.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing a video encoder according to anembodiment of the present disclosure.

FIG. 2 is a block diagram showing a video decoder according to anembodiment of the present disclosure.

FIG. 3 is a view showing a basic coding tree unit according to anembodiment of the present disclosure.

FIG. 4 is a view showing various partitioning types of a coding block.

FIG. 5 is a view showing a partitioning pattern of a coding tree unit.

FIG. 6 is a flowchart illustrating an inter prediction method accordingto an embodiment of the present disclosure.

FIG. 7 is a view showing nonlinear motions of an object.

FIG. 8 is a flowchart illustrating an inter prediction method based onan affine motion according to an embodiment of the present disclosure.

FIG. 9 is a view showing an example of affine seed vectors of eachaffine motion model.

FIG. 10 is a view showing an example of affine vectors of subblocks in a4-parameter motion model.

FIG. 11 is a flowchart illustrating a process of deriving motioninformation of a current block using a merge mode.

FIG. 12 is a view showing an example of candidate blocks used forderiving a merge candidate.

FIG. 13 is a view showing positions of reference samples.

FIG. 14 is a view showing an example of candidate blocks used forderiving a merge candidate.

FIG. 15 is a flowchart illustrating a process of updating aninter-region motion information list.

FIG. 16 is a view showing an embodiment of updating an inter-regionmerge candidate list.

FIG. 17 is a view showing an example in which an index of a previouslystored inter-region merge candidate is updated.

FIG. 18 is a view showing the position of a representative subblock.

FIG. 19 is a view showing an example in which an inter-region motioninformation list is generated for each inter prediction mode.

FIG. 20 is a view showing an example in which an inter-region mergecandidate included in a long-term motion information list is added to amerge candidate list.

FIG. 21 is a view showing an example in which a redundancy check isperformed only on some of merge candidates.

FIG. 22 is a view showing an example in which a redundancy check isomitted for a specific merge candidate.

FIG. 23 is a view showing examples of applying partitioning to a codingblock to obtain a plurality of prediction units using a diagonal line.

FIG. 24 is a view showing examples of applying partitioning to a codingblock to obtain two prediction units.

FIG. 25 is a view showing examples of applying partitioning to a codingblock to obtain a plurality of prediction blocks of different size.

FIG. 26 is a view showing neighboring blocks used for deriving atriangular merge candidate.

FIG. 27 is a view for describing examples of determining availability ofa neighboring block for each triangular prediction unit.

FIG. 28 is a view showing examples of deriving a prediction sample basedon a weighted sum operation of a first prediction sample and a secondprediction sample.

FIG. 29 is a view showing examples of deriving a prediction sample basedon a weighted sum operation of a first prediction sample and a secondprediction sample.

DETAILED DESCRIPTION

Hereafter, an embodiment of the present disclosure will be described indetail with reference to the accompanying drawings.

Encoding and decoding of a video is performed by the unit of block. Forexample, an encoding/decoding process such as transform, quantization,prediction, in-loop filtering, reconstruction or the like may beperformed on a coding block, a transform block, or a prediction block.

Hereinafter, a block to be encoded/decoded will be referred to as a‘current block’. For example, the current block may represent a codingblock, a transform block or a prediction block according to a currentencoding/decoding process step.

In addition, it may be understood that the term ‘unit’ used in thisspecification indicates a basic unit for performing a specificencoding/decoding process, and the term ‘block’ indicates a sample arrayof a predetermined size. Unless otherwise stated, the ‘block’ and ‘unit’may be used to have the same meaning. For example, in an embodimentdescribed below, it may be understood that a coding block and a codingunit have the same meaning.

FIG. 1 is a block diagram showing a video encoder according to anembodiment of the present disclosure.

Referring to FIG. 1, a video encoding apparatus 100 may include apicture partitioning part 110, a prediction part 120 and 125, atransform part 130, a quantization part 135, a rearrangement part 160,an entropy coding part 165, an inverse quantization part 140, an inversetransform part 145, a filter part 150, and a memory 155.

Each of the components shown in FIG. 1 is independently shown torepresent characteristic functions different from each other in a videoencoding apparatus, and it does not mean that each component is formedby the configuration unit of separate hardware or single software. Thatis, each component is included to be listed as a component forconvenience of explanation, and at least two of the components may becombined to form a single component, or one component may be dividedinto a plurality of components to perform a function. Integratedembodiments and separate embodiments of the components are also includedin the scope of the present disclosure if they do not depart from theessence of the present disclosure.

In addition, some of the components are not essential components thatperform essential functions in the present disclosure, but may beoptional components only for improving performance. The presentdisclosure can be implemented by including only components essential toimplement the essence of the present disclosure excluding componentsused for improving performance, and a structure including only theessential components excluding the optional components used forimproving performance is also included in the scope of the presentdisclosure.

The picture partitioning part 110 may apply partitioning to an inputpicture to obtain at least one processing unit. At this point, theprocessing unit may be a prediction unit (PU), a transform unit (TU), ora coding unit (CU). The picture partitioning part 110 may applypartitioning to a picture to obtain a combination of a plurality ofcoding units, prediction units, and transform units, and encode apicture by selecting a combination of a coding unit, a prediction unit,and a transform unit based on a predetermined criterion (e.g., a costfunction).

For example, one picture may be partitioned into a plurality of codingunits. In order to partition the coding units in a picture, a recursivetree structure such as a quad tree structure may be used. A video or acoding unit partitioned into different coding units using the largestcoding unit as a root may be partitioned to have as many child nodes asthe number of partitioned coding units. A coding unit that is notpartitioned any more according to a predetermined restriction become aleaf node. That is, when it is assumed that only square partitioning ispossible for one coding unit, the one coding unit may be partitionedinto up to four different coding units.

Hereinafter, in an embodiment of the present disclosure, the coding unitmay be used as a meaning of a unit performing encoding or a meaning of aunit performing decoding.

The prediction unit may be one that is partitioned in a shape of atleast one square, rectangle or the like of the same size within onecoding unit, or it may be any one prediction unit, among the predictionunits partitioned within one coding unit, that is partitioned to have ashape and/or size different from those of another prediction unit.

If the coding unit is not a smallest coding unit when a prediction unitthat performs intra prediction based on the coding unit is generated,intra prediction may be performed without partitioning a picture into aplurality of prediction units N×N.

The prediction part 120 and 125 may include an inter prediction part 120that performs inter prediction and an intra prediction part 125 thatperforms intra prediction. It may be determined whether to use interprediction or to perform intra prediction for a prediction unit, anddetermine specific information (e.g., intra prediction mode, motionvector, reference picture, etc.) according to each prediction method. Atthis point, a processing unit for performing prediction may be differentfrom a processing unit for determining a prediction method and specificcontent. For example, a prediction method and a prediction mode may bedetermined in a prediction unit, and prediction may be performed in atransform unit. A residual coefficient (residual block) between thegenerated prediction block and the original block may be input into thetransform part 130. In addition, prediction mode information, motionvector information and the like used for prediction may be encoded bythe entropy coding part 165 together with the residual coefficient andtransferred to a decoder. When a specific encoding mode is used, anoriginal block may be encoded as it is and transmitted to a decoderwithout generating a prediction block through the prediction part 120and 125.

The inter prediction part 120 may predict a prediction unit based oninformation on at least one picture among pictures before or after thecurrent picture, and in some cases, it may predict a prediction unitbased on information on a partial area that has been encoded in thecurrent picture. The inter prediction part 120 may include a referencepicture interpolation part, a motion prediction part, and a motioncompensation part.

The reference picture interpolation part may receive reference pictureinformation from the memory 155 and generate sample information of aninteger number of samples or less from the reference picture. In thecase of a luminance sample, a DCT-based 8-tap interpolation filter witha varying filter coefficient may be used to generate sample informationof an integer number of samples or less by the unit of ¼ samples. In thecase of a color difference signal, a DCT-based 4-tap interpolationfilter with a varying filter coefficient may be used to generate sampleinformation of an integer number of samples or less by the unit of ⅛samples.

The motion prediction part may perform motion prediction based on thereference picture interpolated by the reference picture interpolationpart. Various methods such as a full search-based block matchingalgorithm (FBMA), a three-step search (TSS), and a new three-step searchalgorithm (NTS) may be used as a method of calculating a motion vector.The motion vector may have a motion vector value of a unit of ½ or ¼samples based on interpolated samples. The motion prediction part maypredict a current prediction unit by varying the motion predictionmethod. Various methods such as a skip method, a merge method, anadvanced motion vector prediction (AMVP) method, an intra-block copymethod and the like may be used as the motion prediction method.

The intra prediction part 125 may generate a prediction unit based onthe information on reference samples in the neighborhood of the currentblock, which is sample information in the current picture. When a blockin the neighborhood of the current prediction unit is a block on whichinter prediction has been performed and thus the reference sample is asample on which inter prediction has been performed, the referencesample included in the block on which inter prediction has beenperformed may be used in place of reference sample information of ablock in the neighborhood on which intra prediction has been performed.That is, when a reference sample is unavailable, at least one referencesample among available reference samples may be used in place ofunavailable reference sample information.

In the intra prediction, the prediction mode may have an angularprediction mode that uses reference sample information according to aprediction direction, and a non-angular prediction mode that does notuse directional information when performing prediction. A mode forpredicting luminance information may be different from a mode forpredicting color difference information, and intra prediction modeinformation used to predict luminance information or predicted luminancesignal information may be used to predict the color differenceinformation.

If the size of the prediction unit is the same as the size of thetransform unit when intra prediction is performed, the intra predictionmay be performed for the prediction unit based on a sample on the leftside, a sample on the top-left side, and a sample on the top of theprediction unit. However, if the size of the prediction unit isdifferent from the size of the transform unit when the intra predictionis performed, the intra prediction may be performed using a referencesample based on the transform unit. In addition, intra prediction usingN×N partitioning may be used only for the smallest coding unit.

The intra prediction method may generate a prediction block afterapplying an Adaptive Intra Smoothing (AIS) filter to the referencesample according to a prediction mode. The type of the AIS filterapplied to the reference sample may vary. In order to perform the intraprediction method, the intra prediction mode of the current predictionunit may be predicted from the intra prediction mode of the predictionunit existing in the neighborhood of the current prediction unit. When aprediction mode of the current prediction unit is predicted using themode information predicted from the neighboring prediction unit, if theintra prediction modes of the current prediction unit is the same as theprediction unit in the neighborhood, information indicating that theprediction modes of the current prediction unit is the same as theprediction unit in the neighborhood may be transmitted usingpredetermined flag information, and if the prediction modes of thecurrent prediction unit and the prediction unit in the neighborhood aredifferent from each other, prediction mode information of the currentblock may be encoded by performing entropy coding.

In addition, a residual block including a prediction unit that hasperformed prediction based on the prediction unit generated by theprediction part 120 and 125 and residual coefficient information, whichis a difference value of the prediction unit with the original block,may be generated. The generated residual block may be input into thetransform part 130.

The transform part 130 may transform the residual block including theoriginal block and the residual coefficient information of theprediction unit generated through the prediction part 120 and 125 usinga transform method such as Discrete Cosine Transform (DCT) or DiscreteSine Transform (DST). Here, the DCT transform core includes at least oneamong DCT2 and DCT8, and the DST transform core includes DST7. Whetheror not to apply DCT or DST to transform the residual block may bedetermined based on intra prediction mode information of a predictionunit used to generate the residual block. The transform on the residualblock may be skipped. A flag indicating whether or not to skip thetransform on the residual block may be encoded. The transform skip maybe allowed for a residual block having a size smaller than or equal to athreshold, a luma component, or a chroma component under the 4:4:4format.

The quantization part 135 may quantize values transformed into thefrequency domain by the transform part 130. Quantization coefficientsmay vary according to the block or the importance of a video. A valuecalculated by the quantization part 135 may be provided to the inversequantization part 140 and the rearrangement part 160.

The rearrangement part 160 may rearrange coefficient values for thequantized residual coefficients.

The rearrangement part 160 may change coefficients of a two-dimensionalblock shape into a one-dimensional vector shape through a coefficientscanning method. For example, the rearrangement part 160 may scan DCcoefficients up to high-frequency domain coefficients using a zig-zagscan method, and change the coefficients into a one-dimensional vectorshape. According to the size of the transform unit and the intraprediction mode, a vertical scan of scanning the coefficients of atwo-dimensional block shape in the column direction and a horizontalscan of scanning the coefficients of a two-dimensional block shape inthe row direction may be used instead of the zig-zag scan. That is,according to the size of the transform unit and the intra predictionmode, a scan method that will be used may be determined among thezig-zag scan, the vertical direction scan, and the horizontal directionscan.

The entropy coding part 165 may perform entropy coding based on valuescalculated by the rearrangement part 160. Entropy coding may use variousencoding methods such as Exponential Golomb, Context-Adaptive VariableLength Coding (CAVLC), Context-Adaptive Binary Arithmetic Coding(CABAC), and the like.

The entropy coding part 165 may encode various information such asresidual coefficient information and block type information of a codingunit, prediction mode information, partitioning unit information,prediction unit information and transmission unit information, motionvector information, reference frame information, block interpolationinformation, and filtering information input from the rearrangement part160 and the prediction parts 120 and 125.

The entropy coding part 165 may entropy-encode the coefficient value ofa coding unit input from the rearrangement part 160.

The inverse quantization part 140 and the inverse transform part 145inverse-quantize the values quantized by the quantization part 135 andinverse-transform the values transformed by the transform part 130. Theresidual coefficient generated by the inverse quantization part 140 andthe inverse transform part 145 may be combined with the prediction unitpredicted through a motion estimation part, a motion compensation part,and an intra prediction part included in the prediction part 120 and 125to generate a reconstructed block.

The filter part 150 may include at least one among a deblocking filter,an offset correction unit, and an adaptive loop filter (ALF).

The deblocking filter may remove block distortion generated by theboundary between blocks in the reconstructed picture. In order todetermine whether or not to perform deblocking, whether or not to applythe deblocking filter to the current block may be determined based onthe samples included in several columns or rows included in the block. Astrong filter or a weak filter may be applied according to thedeblocking filtering strength needed when the deblocking filter isapplied to a block. In addition, when vertical direction filtering andhorizontal direction filtering are performed in applying the deblockingfilter, horizontal direction filtering and vertical direction filteringmay be processed in parallel.

The offset correction unit may correct an offset to the original videoby the unit of sample for a video on which the deblocking has beenperformed. In order to perform offset correction for a specific picture,it is possible to use a method of dividing samples included in the videointo a certain number of areas, determining an area to perform offset,and applying the offset to the area, or a method of applying an offsetconsidering edge information of each sample.

Adaptive Loop Filtering (ALF) may be performed based on a value obtainedby comparing the reconstructed and filtered video with the originalvideo. After dividing the samples included in the video intopredetermined groups, one filter to be applied to a corresponding groupmay be determined, and filtering may be performed differently for eachgroup. A luminance signal, which is the information related to whetheror not to apply ALF, may be transmitted for each coding unit (CU), andthe shape and filter coefficient of an ALF filter to be applied may varyaccording to each block. In addition, an ALF filter of the same type(fixed type) may be applied regardless of the characteristic of a blockto be applied.

The memory 155 may store the reconstructed block or picture calculatedthrough the filter part 150, and the reconstructed and stored block orpicture may be provided to the prediction part 120 and 125 when interprediction is performed.

FIG. 2 is a block diagram showing a video decoder according to anembodiment of the present disclosure.

Referring to FIG. 2, a video decoder 200 may include an entropy decodingpart 210, a rearrangement part 215, an inverse quantization part 220, aninverse transform part 225, a prediction part 230 and 235, a filter part240, and a memory 245.

When a video bitstream is input from a video encoder, the inputbitstream may be decoded in a procedure opposite to that of the videoencoder.

The entropy decoding part 210 may perform entropy decoding in aprocedure opposite to that of performing entropy coding in the entropydecoding part of the video encoder. For example, various methodscorresponding to the method performed by the video encoder, such asExponential Golomb, Context-Adaptive Variable Length Coding (CAVLC), andContext-Adaptive Binary Arithmetic Coding (CABAC), may be applied.

The entropy decoding part 210 may decode information related to intraprediction and inter prediction performed by the encoder.

The rearrangement part 215 may perform rearrangement on the bitstreamentropy-decoded by the entropy decoding part 210 based on therearrangement method performed by the encoder. The coefficientsexpressed in a one-dimensional vector shape may be reconstructed andrearranged as coefficients of two-dimensional block shape. Therearrangement part 215 may receive information related to coefficientscanning performed by the encoding part and perform reconstructionthrough a method of inverse-scanning based on the scanning orderperformed by the corresponding encoding part.

The inverse quantization part 220 may perform inverse quantization basedon a quantization parameter provided by the encoder and a coefficientvalue of the rearranged block.

The inverse transform part 225 may perform inverse transform on thetransform, i.e., DCT or DST, performed by the transform part on a resultof the quantization performed by the video encoder, i.e., inverse DCT orinverse DST. Here, the DCT transform core may include at least one amongDCT2 and DCT8, and the DST transform core may include DST7.Alternatively, when the transform is skipped in the video encoder, eventhe inverse transform part 225 may not perform the inverse transform.The inverse transform may be performed based on a transmission unitdetermined by the video encoder. The inverse transform part 225 of thevideo decoder may selectively perform a transform technique (e.g., DCTor DST) according to a plurality of pieces of information such as aprediction method, a size of a current block, a prediction direction andthe like.

The prediction part 230 and 235 may generate a prediction block based oninformation related to generation of a prediction block provided by theentropy decoder 210 and information on a previously decoded block orpicture provided by the memory 245.

As described above, if the size of the prediction unit and the size ofthe transform unit are the same when intra prediction is performed inthe same manner as the operation of the video encoder, intra predictionis performed on the prediction unit based on the sample existing on theleft side, the sample on the top-left side, and the sample on the top ofthe prediction unit. However, if the size of the prediction unit and thesize of the transform unit are different when intra prediction isperformed, intra prediction may be performed using a reference samplebased on a transform unit. In addition, intra prediction using N×Npartitioning may be used only for the smallest coding unit.

The prediction part 230 and 235 may include a prediction unitdetermination part, an inter prediction part, and an intra predictionpart. The prediction unit determination part may receive variousinformation such as prediction unit information input from the entropydecoding part 210, prediction mode information of the intra predictionmethod, information related to motion prediction of an inter predictionmethod, and the like, identify the prediction unit from the currentcoding unit, and determine whether the prediction unit performs interprediction or intra prediction. The inter prediction part 230 mayperform inter prediction on the current prediction unit based oninformation included in at least one picture among pictures before orafter the current picture including the current prediction unit by usinginformation necessary for inter prediction of the current predictionunit provided by the video encoder. Alternatively, the inter predictionpart 230 may perform inter prediction based on information on a partialarea previously reconstructed in the current picture including thecurrent prediction unit.

In order to perform inter prediction, it may be determined, based on thecoding unit, whether the motion prediction method of the prediction unitincluded in a corresponding coding unit is a skip mode, a merge mode, amotion vector prediction mode (AMVP mode), or an intra-block copy mode.

The intra prediction part 235 may generate a prediction block based onthe information on the sample in the current picture. When theprediction unit is a prediction unit that has performed intraprediction, the intra prediction may be performed based on intraprediction mode information of the prediction unit provided by the videoencoder. The intra prediction part 235 may include an Adaptive IntraSmoothing (AIS) filter, a reference sample interpolation part, and a DCfilter. The AIS filter is a part that performs filtering on thereference sample of the current block, and may determine whether or notto apply the filter according to the prediction mode of the currentprediction unit and apply the filter. AIS filtering may be performed onthe reference sample of the current block by using the prediction modeand AIS filter information of the prediction unit provided by the videoencoder. When the prediction mode of the current block is a mode thatdoes not perform AIS filtering, the AIS filter may not be applied.

When the prediction mode of the prediction unit is a prediction unitthat performs intra prediction based on a sample value obtained byinterpolating the reference sample, the reference sample interpolationpart may generate a reference sample of a sample unit having an integervalue or less by interpolating the reference sample. When the predictionmode of the current prediction unit is a prediction mode that generatesa prediction block without interpolating the reference sample, thereference sample may not be interpolated. The DC filter may generate aprediction block through filtering when the prediction mode of thecurrent block is the DC mode.

The reconstructed block or picture may be provided to the filter part240. The filter part 240 may include a deblocking filter, an offsetcorrection unit, and an ALF.

Information on whether a deblocking filter is applied to a correspondingblock or picture and information on whether a strong filter or a weakfilter is applied when a deblocking filter is applied may be provided bythe video encoder. The deblocking filter of the video decoder may beprovided with information related to the deblocking filter provided bythe video encoder, and the video decoder may perform deblockingfiltering on a corresponding block.

The offset correction unit may perform offset correction on thereconstructed video based on the offset correction type and offset valueinformation applied to the video when encoding is performed.

The ALF may be applied to a coding unit based on information on whetheror not to apply the ALF and information on ALF coefficients provided bythe encoder. The ALF information may be provided to be included in aspecific parameter set.

The memory 245 may store the reconstructed picture or block and use itas a reference picture or a reference block and may provide thereconstructed picture to an output unit.

FIG. 3 is a view showing a basic coding tree unit according to anembodiment of the present disclosure.

A coding block of a maximum size may be defined as a coding tree block.A picture is partitioned into a plurality of coding tree units (CTUs).The coding tree unit is a coding unit having a maximum size and may bereferred to as a Large Coding Unit (LCU). FIG. 3 shows an example inwhich a picture is partitioned into a plurality of coding tree units.

The size of the coding tree unit may be defined at a picture level or asequence level. To this end, information indicating the size of thecoding tree unit may be signaled through a picture parameter set or asequence parameter set.

For example, the size of the coding tree unit for the entire picture ina sequence may be set to 128×128. Alternatively, at the picture level,any one among 128×128 and 256×256 may be determined as the size of thecoding tree unit. For example, the size of the coding tree unit may beset to 128×128 in a first picture, and the size of the coding tree unitmay be set to 256×256 in a second picture.

Coding blocks may be generated by partitioning a coding tree unit. Thecoding block indicates a basic unit for performing encoding/decoding.For example, prediction or transform may be performed for each codingblock, or a prediction encoding mode may be determined for each codingblock. Here, the prediction encoding mode indicates a method ofgenerating a prediction picture. For example, the prediction encodingmode may include prediction within a picture (intra prediction),prediction between pictures (inter prediction), current picturereferencing (CPR) or intra-block copy (IBC), or combined prediction. Forthe coding block, a prediction block may be generated by using at leastone prediction encoding mode among the intra prediction, the interprediction, the current picture referencing, and the combinedprediction.

Information indicating the prediction encoding mode of the current blockmay be signaled through a bitstream. For example, the information may bea 1-bit flag indicating whether the prediction encoding mode is an intramode or an inter mode. Only when the prediction encoding mode of thecurrent block is determined as the inter mode, the current picturereferencing or the combined prediction may be used.

The current picture reference is for setting the current picture as areference picture and obtaining a prediction block of the current blockfrom an area that has already been encoded/decoded in the currentpicture. Here, the current picture means a picture including the currentblock. Information indicating whether the current picture reference isapplied to the current block may be signaled through a bitstream. Forexample, the information may be a 1-bit flag. When the flag is true, theprediction encoding mode of the current block may be determined as thecurrent picture reference, and when the flag is false, the predictionmode of the current block may be determined as inter prediction.

Alternatively, the prediction encoding mode of the current block may bedetermined based on a reference picture index. For example, when thereference picture index indicates the current picture, the predictionencoding mode of the current block may be determined as the currentpicture reference. When the reference picture index indicates a pictureother than the current picture, the prediction encoding mode of thecurrent block may be determined as inter prediction. That is, thecurrent picture reference is a prediction method using information on anarea in which encoding/decoding has been completed in the currentpicture, and inter prediction is a prediction method using informationon another picture in which the encoding/decoding has been completed.

The combined prediction represents an encoding mode in which two or moreamong the intra prediction, the inter prediction, and the currentreference picture are combined. For example, when the combinedprediction is applied, a first prediction block may be generated basedon one among the intra prediction, the inter prediction, and the currentpicture referencing, and a second prediction block may be generatedbased on another one. When the first prediction block and the secondprediction block are generated, a final prediction block may begenerated through an average operation or a weighted sum operation ofthe first prediction block and the second prediction block. Informationindicating whether or not the combined prediction is applied may besignaled through a bitstream. The information may be a 1-bit flag.

FIG. 4 is a view showing various partitioning types of a coding block.

The coding block may be partitioned into a plurality of coding blocksbased on quad tree partitioning, binary tree partitioning, or ternarytree partitioning. The partitioned coding block may be partitioned againinto a plurality of coding blocks based on the quad tree partitioning,the binary tree partitioning, or the ternary tree partitioning.

The quad tree partitioning refers to a partitioning technique thatpartitions a current block into four blocks. As a result of the quadtree partitioning, the current block may be partitioned into foursquare-shaped partitions (see ‘SPLIT_QT’ of FIG. 4(a)).

The binary tree partitioning refers to a partitioning technique thatpartitions a current block into two blocks. Partitioning a current blockinto two blocks along the vertical direction (i.e., using a verticalline crossing the current block) may be referred to as verticaldirection binary tree partitioning, and partitioning a current blockinto two blocks along the horizontal direction (i.e., using a horizontalline crossing the current block) may be referred to as horizontaldirection binary tree partitioning. As a result of the binary treepartitioning, the current block may be partitioned into two non-squareshaped partitions. ‘SPLIT_BT_VER’ of FIG. 4(b) shows a result of thevertical direction binary tree partitioning, and ‘SPLIT_BT_HOR’ of FIG.4(c) shows a result of the horizontal direction binary treepartitioning.

The ternary tree partitioning refers to a partitioning technique thatpartitions a current block into three blocks. Partitioning a currentblock into three blocks along the vertical direction (i.e., using twovertical lines crossing the current block) may be referred to asvertical direction ternary tree partitioning, and partitioning a currentblock into three blocks along the horizontal direction (i.e., using twohorizontal lines crossing the current block) may be referred to ashorizontal direction ternary tree partitioning. As a result of theternary tree partitioning, the current block may be partitioned intothree non-square shaped partitions. At this point, the width/height of apartition positioned at the center of the current block may be twice aslarge as the width/height of the other partitions. ‘SPLIT_TT_VER’ ofFIG. 4(d) shows a result of the vertical direction ternary treepartitioning, and ‘SPLIT_TT_HOR’ of FIG. 4(e) shows a result of thehorizontal direction ternary tree partitioning.

The number of times of partitioning a coding tree unit may be defined asa partitioning depth. The maximum partitioning depth of a coding treeunit may be determined at the sequence or picture level. Accordingly,the maximum partitioning depth of a coding tree unit may be differentfor each sequence or picture.

Alternatively, the maximum partitioning depth for each partitioningtechnique may be individually determined. For example, the maximumpartitioning depth allowed for the quad tree partitioning may bedifferent from the maximum partitioning depth allowed for the binarytree partitioning and/or the ternary tree partitioning.

The encoder may signal information indicating at least one among thepartitioning type and the partitioning depth of the current blockthrough a bitstream. The decoder may determine the partitioning type andthe partitioning depth of a coding tree unit based on the informationparsed from the bitstream.

FIG. 5 is a view showing a partitioning pattern of a coding tree unit.

Partitioning a coding block using a partitioning technique such as quadtree partitioning, binary tree partitioning, and/or ternary treepartitioning may be referred to as multi-tree partitioning.

Coding blocks generated by applying the multi-tree partitioning to acoding block may be referred to as lower coding blocks. When thepartitioning depth of a coding block is k, the partitioning depth of thelower coding blocks is set to k+1.

Contrarily, for coding blocks having a partitioning depth of k+1, acoding block having a partitioning depth of k may be referred to as anupper coding block.

The partitioning type of the current coding block may be determinedbased on at least one among a partitioning type of an upper coding blockand a partitioning type of a neighboring coding block. Here, theneighboring coding block is a coding block adjacent to the currentcoding block and may include at least one among a top neighboring blockand a left neighboring block of the current coding block, and aneighboring block adjacent to the top-left corner. Here, thepartitioning type may include at least one among whether quad treepartitioning is applied, whether binary tree partitioning is applied, abinary tree partitioning direction, whether ternary tree partitioning isapplied, and a ternary tree partitioning direction.

In order to determine a partitioning type of a coding block, informationindicating whether or not the coding block can be partitioned may besignaled through a bitstream. The information is a 1-bit flag of‘split_cu_flag’, and when the flag is true, it indicates that the codingblock is partitioned by a quad tree partitioning technique.

When split_cu_flag is true, information indicating whether the codingblock is quad-tree partitioned may be signaled through a bitstream. Theinformation is a 1-bit flag of split_qt_flag, and when the flag is true,the coding block may be partitioned into four blocks.

For example, in the example shown in FIG. 5, as a coding tree unit isquad-tree partitioned, four coding blocks having a partitioning depth of1 are generated. In addition, it is shown that quad tree partitioning isapplied again to the first and fourth coding blocks among the fourcoding blocks generated as a result of the quad tree partitioning. As aresult, four coding blocks having a partitioning depth of 2 may begenerated.

In addition, coding blocks having a partitioning depth of 3 may begenerated by applying the quad tree partitioning again to a coding blockhaving a partitioning depth of 2.

When quad tree partitioning is not applied to the coding block, whetherbinary tree partitioning or ternary tree partitioning is performed onthe coding block may be determined considering at least one among thesize of the coding block, whether the coding block is positioned at thepicture boundary, the maximum partitioning depth, and the partitioningtype of a neighboring block. When it is determined to perform binarytree partitioning or ternary tree partitioning on the coding block,information indicating the partitioning direction may be signaledthrough a bitstream. The information may be a 1-bit flag ofmtt_split_cu_vertical_flag. Based on the flag, whether the partitioningdirection is a vertical direction or a horizontal direction may bedetermined. Additionally, information indicating whether binary treepartitioning or ternary tree partitioning is applied to the coding blockmay be signaled through a bitstream. The information may be a 1-bit flagof mtt_split_cu_binary_flag. Based on the flag, whether binary treepartitioning or ternary tree partitioning is applied to the coding blockmay be determined.

For example, in the example shown in FIG. 5, it is shown that verticaldirection binary tree partitioning is applied to a coding block having apartitioning depth of 1, vertical direction ternary tree partitioning isapplied to the left-side coding block among the coding blocks generatedas a result of the partitioning, and vertical direction binary treepartitioning is applied to the right-side coding block.

Inter prediction is a prediction encoding mode that predicts a currentblock by using information of a previous picture. For example, a blockat the same position as the current block in the previous picture(hereinafter, a collocated block) may be set as the prediction block ofthe current block. Hereinafter, a prediction block generated based on ablock at the same position as the current block will be referred to as acollocated prediction block.

On the other hand, when an object existing in the previous picture hasmoved to another position in the current picture, the current block maybe effectively predicted by using a motion of the object. For example,when the moving direction and the size of an object can be known bycomparing the previous picture and the current picture, a predictionblock (or a prediction picture) of the current block may be generatedconsidering motion information of the object. Hereinafter, theprediction block generated using motion information may be referred toas a motion prediction block.

A residual block may be generated by subtracting the prediction blockfrom the current block. At this point, when there is a motion of anobject, the energy of the residual block may be reduced by using themotion prediction block instead of the collocated prediction block, andtherefore, compression performance of the residual block can beimproved.

As described above, generating a prediction block by using motioninformation may be referred to as motion compensation prediction. Inmost inter prediction, a prediction block may be generated based on themotion compensation prediction.

The motion information may include at least one among a motion vector, areference picture index, a prediction direction, and a bidirectionalweight index. The motion vector indicates the moving direction and thesize of an object. The reference picture index specifies a referencepicture of the current block among reference pictures included in areference picture list. The prediction direction indicates any one amongunidirectional L0 prediction, unidirectional L1 prediction, andbidirectional prediction (L0 prediction and L1 prediction). According tothe prediction direction of the current block, at least one among motioninformation in the L0 direction and motion information in the L1direction may be used. The bidirectional weight index specifies aweighting value applied to a L0 prediction block and a weighting valueapplied to a L1 prediction block.

FIG. 6 is a flowchart illustrating an inter prediction method accordingto an embodiment of the present disclosure.

Referring to FIG. 6, the inter prediction method includes the steps ofdetermining an inter prediction mode of a current block (S601),acquiring motion information of the current block according to thedetermined inter prediction mode (S602), and performing motioncompensation prediction for the current block based on the acquiredmotion information (S603).

Here, the inter prediction mode represents various techniques fordetermining motion information of the current block, and may include aninter prediction mode that uses translational motion information and aninter prediction mode that uses affine motion information. For example,the inter prediction mode using translational motion information mayinclude a merge mode and a motion vector prediction mode, and the interprediction mode using affine motion information may include an affinemerge mode and an affine motion vector prediction mode. The motioninformation of the current block may be determined based on aneighboring block adjacent to the current block or information parsedfrom a bitstream according to the inter prediction mode.

Hereinafter, the inter prediction method using affine motion informationwill be described in detail.

FIG. 7 is a view showing nonlinear motions of an object.

A nonlinear motion of an object may be generated in a video. Forexample, as shown in the example of FIG. 7, a nonlinear motion of anobject, such as zoom-in, zoom-out, rotation, affine transform or thelike of a camera, may occur. When a nonlinear motion of an objectoccurs, the motion of the object cannot be effectively expressed with atranslational motion vector. Accordingly, encoding efficiency can beimproved by using an affine motion instead of a translational motion inan area where a nonlinear motion of an object occurs.

FIG. 8 is a flowchart illustrating an inter prediction method based onan affine motion according to an embodiment of the present disclosure.

Whether an inter prediction technique based on an affine motion isapplied to the current block may be determined based on the informationparsed from a bitstream. Specifically, whether the inter predictiontechnique based on an affine motion is applied to the current block maybe determined based on at least one among a flag indicating whether theaffine merge mode is applied to the current block and a flag indicatingwhether the affine motion vector prediction mode is applied to thecurrent block.

When the inter prediction technique based on an affine motion is appliedto the current block, an affine motion model of the current block may bedetermined (S1101→S801). The affine motion model may be determined as atleast one among a six-parameter affine motion model and a four-parameteraffine motion model. The six-parameter affine motion model expresses anaffine motion using six parameters, and the four-parameter affine motionmodel expresses an affine motion using four parameters.

Equation 1 expresses an affine motion using six parameters. The affinemotion represents a translational motion for a predetermined areadetermined by affine seed vectors.v=ax−by+evy=cx+dy+f  [Equation 1]

When an affine motion is expressed using six parameters, a complicatedmotion can be expressed. However, as the number of bits required forencoding each of the parameters increases, encoding efficiency may belowered. Accordingly, the affine motion may be expressed using fourparameters. Equation 2 expresses an affine motion using four parameters.v=ax−by+evy=bx+ay+f  [Equation 2]

Information for determining an affine motion model of the current blockmay be encoded and signaled through a bitstream. For example, theinformation may be a 1-bit flag of ‘affine_type_flag’. When the value ofthe flag is 0, it may indicate that a 4-parameter affine motion model isapplied, and when the value of the flag is 1, it may indicate that a6-parameter affine motion model is applied. The flag may be encoded bythe unit of slice, tile, or block (e.g., by the unit of coding block orcoding tree). When a flag is signaled at the slice level, an affinemotion model determined at the slice level may be applied to all blocksbelonging to the slice.

Alternatively, an affine motion model of the current block may bedetermined based on an affine inter prediction mode of the currentblock. For example, when the affine merge mode is applied, the affinemotion model of the current block may be determined as a 4-parametermotion model. On the other hand, when the affine motion vectorprediction mode is applied, information for determining the affinemotion model of the current block may be encoded and signaled through abitstream. For example, when the affine motion vector prediction mode isapplied to the current block, the affine motion model of the currentblock may be determined based on the 1-bit flag of ‘affine_type_flag’.

Next, an affine seed vector of the current block may be derived(S1102→S802). When a 4-parameter affine motion model is selected, motionvectors at two control points of the current block may be derived. Onthe other hand, when a 6-parameter affine motion model is selected,motion vectors at three control points of the current block may bederived. The motion vector at a control point may be referred to as anaffine seed vector. The control point may include at least one among thetop-left corner, the top-right corner, and the bottom-left corner of thecurrent block.

FIG. 9 is a view showing an example of affine seed vectors of eachaffine motion model.

In the 4-parameter affine motion model, affine seed vectors may bederived for two among the top-left corner, the top-right corner, and thebottom-left corner. For example, as shown in the example of FIG. 9(a),when a 4-parameter affine motion model is selected, an affine vector maybe derived using the affine seed vector sv₀ for the top-left corner ofthe current block (e.g., top-left sample (x1, y1)) and the affine seedvector sv₁ for the top-right corner of the current block (e.g., thetop-right sample (x1, y1)). It is also possible to use an affine seedvector for the bottom-left corner instead of the affine seed vector forthe top-left corner, or use an affine seed vector for the bottom-leftcorner instead of the affine seed vector for the top-right corner.

In the 6-parameter affine motion model, affine seed vectors may bederived for the top-left corner, the top-right corner, and thebottom-left corner. For example, as shown in the example of FIG. 9(b),when a 6-parameter affine motion model is selected, an affine vector maybe derived using the affine seed vector sv₀ for the top-left corner ofthe current block (e.g., top-left sample (x1, y1)), the affine seedvector sv₁ for the top-right corner of the current block (e.g., thetop-right sample (x1, y1)), and the affine seed vector sv₂ for thetop-left corner of the current block (e.g., top-left sample (x2, y2)).

In the embodiment described below, in the 4-parameter affine motionmodel, the affine seed vectors of the top-left control point and thetop-right control point will be referred to as a first affine seedvector and a second affine seed vector, respectively. In the embodimentsusing the first affine seed vector and the second affine seed vectordescribed below, at least one among the first affine seed vector and thesecond affine seed vector may be replaced by the affine seed vector ofthe bottom-left control point (a third affine seed vector) or the affineseed vector of the bottom-right control point (a fourth affine seedvector).

In addition, in the 6-parameter affine motion model, the affine seedvectors of the top-left control point, the top-right control point, andthe bottom-left control point will be referred to as a first affine seedvector, a second affine seed vector, and a third affine seed vector,respectively. In the embodiments using the first affine seed vector, thesecond affine seed vector, and the third affine seed vector describedbelow, at least one among the first affine seed vector, the secondaffine seed vector, and the third affine seed vector may be replaced bythe affine seed vector of the bottom-right control point (a fourthaffine seed vector).

An affine vector may be derived for each subblock by using the affineseed vectors (S803). Here, the affine vector represents a translationalmotion vector derived based on the affine seed vectors. The affinevector of a subblock may be referred to as an affine subblock motionvector or a subblock motion vector.

FIG. 10 is a view showing an example of affine vectors of subblocks in a4-parameter motion model.

The affine vector of the subblock may be derived based on the positionof the control point, the position of the subblock, and the affine seedvector. For example, Equation 3 shows an example of deriving an affinesubblock vector.

$\begin{matrix}{{v_{x} = {{\frac{( {{sv}_{1x} - {sv}_{0x}} )}{( {x_{1} - x_{0}} )}( {x - x_{0}} )} - {\frac{( {{sv}_{1y} - {sv}_{0y}} )}{( {x_{1} - x_{0}} )}( {y - y_{0}} )} + {sv}_{0x}}}{v_{y} = {{\frac{( {{sv}_{1y} - {sv}_{0y}} )}{( {x_{1} - x_{0}} )}( {x - x_{0}} )} - {\frac{( {{sv}_{1x} - {sv}_{0x}} )}{( {x_{1} - x_{0}} )}( {y - y_{0}} )} + {sv}_{0y}}}} & \lbrack {{Equation}\mspace{14mu} 3} \rbrack\end{matrix}$

In Equation 3, (x, y) denotes the position of a subblock. Here, theposition of a subblock indicates the position of a reference sampleincluded in the subblock. The reference sample may be a samplepositioned at the top-left corner of the subblock, or a sample of whichat least one among the x-axis and y-axis coordinates is a center point.(x₀, y₀) denotes the position of the first control point, and (sv_(0x),sv_(0y)) denotes the first affine seed vector. In addition, (x₁, y₁)denotes the position of the second control point, and (sv_(1x), sv_(1y))denotes the second affine seed vector.

When the first control point and the second control point correspond tothe top-left corner and the top-right corner of the current blockrespectively, x₁-x₀ may be set to a value equal to the width of thecurrent block.

Thereafter, motion compensation prediction for each subblock may beperformed using the affine vector of each subblock (S1104→S804). As aresult of performing the motion compensation prediction, a predictionblock for each subblock may be generated. The prediction blocks of thesubblocks may be set as the prediction blocks of the current block.

Next, an inter prediction method using translational motion informationwill be described in detail.

Motion information of the current block may be derived from motioninformation of another block. Here, another block may be a blockencoded/decoded by inter prediction before the current block. Settingthe motion information of the current block to be equal to the motioninformation of another block may be defined as a merge mode. Inaddition, setting the motion vector of another block as the predictionvalue of the motion vector of the current block may be defined as amotion vector prediction mode.

FIG. 11 is a flowchart illustrating a process of deriving motioninformation of a current block using a merge mode.

A merge candidate of the current block may be derived (S1101). The mergecandidate of the current block may be derived from a blockencoded/decoded by inter prediction before the current block.

FIG. 12 is a view showing an example of candidate blocks used forderiving a merge candidate.

The candidate blocks may include at least one among neighboring blocksincluding a sample adjacent to the current block or non-neighboringblocks including a sample not adjacent to the current block.Hereinafter, samples for determining candidate blocks are defined asreference samples. In addition, a reference sample adjacent to thecurrent block is referred to as a neighboring reference sample, and areference sample not adjacent to the current block is referred to as anon-neighboring reference sample.

The neighboring reference sample may be included in a neighboring columnof the leftmost column of the current block or a neighboring row of theuppermost row of the current block. For example, when the coordinates ofthe top-left sample of the current block is (0, 0), at least one among ablock including a reference sample at the position of (−1, H−1), a blockincluding a reference sample at the position of (W−1, −1), a blockincluding a reference sample at the position of (W, −1), a blockincluding a reference sample at the position of (−1, H), and a blockincluding a reference sample at the position of (−1, −1) may be used asa candidate block. Referring to the drawing, neighboring blocks of index0 to 4 may be used as candidate blocks.

The non-neighboring reference sample represents a sample of which atleast one among an x-axis distance and a y-axis distance from areference sample adjacent to the current block has a predefined value.For example, at least one among a block including a reference sample ofwhich the x-axis distance from the left reference sample is a predefinedvalue, a block including a non-neighboring sample of which the y-axisdistance from the top reference sample is a predefined value, and ablock including a non-neighboring sample of which the x-axis distanceand the y-axis distance from the top-left reference sample arepredefined values may be used as a candidate block. The predefinedvalues may be a natural number such as 4, 8, 12, 16 or the like.Referring to the drawing, at least one among the blocks of index 5 to 26may be used as a candidate block.

A sample not positioned on the same vertical line, horizontal line, ordiagonal line as the neighboring reference sample may be set as anon-neighboring reference sample.

FIG. 13 is a view showing positions of reference samples.

As shown in the example of FIG. 13, the x coordinates of the topnon-neighboring reference samples may be set to be different from the xcoordinates of the top neighboring reference samples. For example, whenthe position of the top neighboring reference sample is (W−1, −1), theposition of a top non-neighboring reference sample separated as much asN from the top neighboring reference sample on the y-axis may be set to((W/2)−1, −1−N), and the position of a top non-neighboring referencesample separated as much as 2N from the top neighboring reference sampleon the y-axis may be set to (0, −1−2N). That is, the position of anon-adjacent reference sample may be determined based on the position ofan adjacent reference sample and a distance from the adjacent referencesample.

Hereinafter, a candidate block including a neighboring reference sampleamong the candidate blocks is referred to as a neighboring block, and ablock including a non-neighboring reference sample is referred to as anon-neighboring block.

When the distance between the current block and the candidate block isgreater than or equal to a threshold value, the candidate block may beset to be unavailable as a merge candidate. The threshold value may bedetermined based on the size of the coding tree unit. For example, thethreshold value may be set to the height (ctu_height) of the coding treeunit or a value obtained by adding or subtracting an offset to or fromthe height (e.g., ctu_height±N) of the coding tree unit. The offset N isa value predefined in the encoder and the decoder, and may be set to 4,8, 16, 32 or ctu_height.

When the difference between the y-axis coordinate of the current blockand the y-axis coordinate of a sample included in a candidate block isgreater than the threshold value, the candidate block may be determinedto be unavailable as a merge candidate.

Alternatively, a candidate block that does not belong to the same codingtree unit as the current block may be set to be unavailable as a mergecandidate. For example, when a reference sample deviates from the topboundary of a coding tree unit to which the current block belongs, acandidate block including the reference sample may be set to beunavailable as a merge candidate.

When the top boundary of the current block is adjacent to the topboundary of the coding tree unit, a plurality of candidate blocks isdetermined to be unavailable as a merge candidate, and thus theencoding/decoding efficiency of the current block may decrease. To solvethis problem, candidate blocks may be set so that the number ofcandidate blocks positioned on the left side of the current block isgreater than the number of candidate blocks positioned on the top of thecurrent block.

FIG. 14 is a view showing an example of candidate blocks used forderiving a merge candidate.

As shown in the example of FIG. 14, top blocks belonging to top N blockcolumns of the current block and left-side blocks belonging to Mleft-side block columns of the current block may be set as candidateblocks. At this point, the number of left-side candidate blocks may beset to be greater than the number of top candidate blocks by setting Mto be greater than N.

For example, the difference between the y-axis coordinate of thereference sample in the current block and the y-axis coordinate of thetop block that can be used as a candidate block may be set not to exceedN times of the height of the current block. In addition, the differencebetween the x-axis coordinate of the reference sample in the currentblock and the x-axis coordinate of the left-side block that can be usedas a candidate block may be set not to exceed M times of the width ofthe current block.

For example, in the example shown in FIG. 14, it is shown that blocksbelonging to the top two block columns of the current block and blocksbelonging to the left five block columns of the current block are set ascandidate blocks.

A merge candidate may also be derived from a temporally neighboringblock included in a picture different from the current block. Forexample, a merge candidate may be derived from a collocated blockincluded in a collocated picture.

The motion information of the merge candidate may be set to be equal tothe motion information of the candidate block. For example, at least oneamong a motion vector, a reference picture index, a predictiondirection, and a bidirectional weight index of the candidate block maybe set as motion information of the merge candidate.

A merge candidate list including merge candidates may be generated(S1102). The merge candidates may be divided into an adjacent mergecandidate derived from a neighboring block adjacent to the current blockand a non-adjacent merge candidate derived from a non-neighboring block.

Indexes of the merge candidates in the merge candidate list may beassigned in a predetermined order. For example, an index assigned to anadjacent merge candidate may have a value smaller than an index assignedto a non-adjacent merge candidate. Alternatively, an index may beassigned to each of the merge candidates based on the index of eachblock shown in FIG. 12 or 14.

When a plurality of merge candidates is included in the merge candidatelist, at least one among the plurality of merge candidates may beselected (S1103). At this point, information indicating whether motioninformation of the current block is derived from an adjacent mergecandidate may be signaled through a bitstream. The information may be a1-bit flag. For example, a syntax element isAdjancentMergeFlagindicating whether the motion information of the current block isderived from an adjacent merge candidate may be signaled through abitstream. When the value of the syntax element isAdjancentMergeFlag is1, motion information of the current block may be derived based on theadjacent merge candidate. On the other hand, when the value of thesyntax element isAdjancentMergeFlag is 0, motion information of thecurrent block may be derived based on a non-adjacent merge candidate.

Information for specifying any one among a plurality of merge candidatesmay be signaled through a bitstream. For example, information indicatingan index of any one among the merge candidates included in the mergecandidate list may be signaled through a bitstream.

When isAdjacentMergeflag is 1, syntax element merge_idx specifying anyone among the adjacent merge candidates may be signaled. The maximumvalue of syntax element merge_idx may be set to a value obtained bysubtracting 1 from the number of adjacent merge candidates.

When isAdjacentMergeflag is 0, syntax element NA_merge_idx specifyingany one among the non-adjacent merge candidates may be signaled. Thesyntax element NA_merge_idx represents a value obtained by subtractingthe number of adjacent merge candidates from the index of thenon-adjacent merge candidate. The decoder may select a non-adjacentmerge candidate by adding the number of adjacent merge candidates to anindex specified by NA_merge_idx.

When the number of merge candidates included in the merge candidate listis smaller than a threshold value, the merge candidate included in theinter-region motion information list may be added to the merge candidatelist. Here, the threshold value may be the maximum number of mergecandidates that the merge candidate list may include or a value obtainedby subtracting an offset from the maximum number of merge candidates.The offset may be a natural number such as 1, 2 or the like. Theinter-region motion information list may include a merge candidatederived based on a block encoded/decoded before the current block.

The inter-region motion information list includes a merge candidatederived from a block encoded/decoded based on inter prediction in thecurrent picture. For example, motion information of a merge candidateincluded in the inter-region motion information list may be set to beequal to motion information of a block encoded/decoded based on interprediction. Here, the motion information may include at least one amonga motion vector, a reference picture index, a prediction direction, anda bidirectional weight index.

For convenience of explanation, a merge candidate included in theinter-region motion information list will be referred to as aninter-region merge candidate.

The maximum number of merge candidates that the inter-region motioninformation list may include may be predefined by an encoder and adecoder. For example, the maximum number of merge candidates that theinter-region motion information list may include may be 1, 2, 3, 4, 5,6, 7, 8 or more (e.g., 16).

Alternatively, information indicating the maximum number of mergecandidates in the inter-region motion information list may be signaledthrough a bitstream. The information may be signaled at the sequence,picture, or slice level.

Alternatively, the maximum number of merge candidates of theinter-region motion information list may be determined according to thesize of a picture, the size of a slice, or the size of a coding treeunit.

The inter-region motion information list may be initialized by the unitof picture, slice, tile, brick, coding tree unit, or coding tree unitline (row or column). For example, when a slice is initialized, theinter-region motion information list is also initialized, and theinter-region motion information list may not include any mergecandidate.

Alternatively, information indicating whether or not to initialize theinter-region motion information list may be signaled through abitstream. The information may be signaled at the slice, tile, brick, orblock level. Until the information indicates to initialize theinter-region motion information list, a previously configuredinter-region motion information list may be used.

Alternatively, information on the initial inter-region merge candidatemay be signaled through a picture parameter set or a slice header.Although the slice is initialized, the inter-region motion informationlist may include the initial inter-region merge candidate. Accordingly,an inter-region merge candidate may be used for a block that is thefirst encoding/decoding target in the slice.

Blocks are encoded/decoded according to an encoding/decoding order, andblocks encoded/decoded based on inter prediction may be sequentially setas an inter-region merge candidate according to an encoding/decodingorder.

FIG. 15 is a flowchart illustrating a process of updating aninter-region motion information list.

When inter prediction is performed on the current block (S1501), aninter-region merge candidate may be derived based on the current block(S1502). Motion information of the inter-region merge candidate may beset to be equal to the motion information of the current block.

When the inter-region motion information list is empty (S1503), theinter-region merge candidate derived based on the current block may beadded to the inter-region motion information list (S1504).

When the inter-region motion information list already includes theinter-region merge candidate (S1503), a redundancy check may beperformed on the motion information of the current block (or theinter-region merge candidate derived based on the current block)(S1505). The redundancy check is for determining whether motioninformation of an inter-region merge candidate previously stored in theinter-region motion information list and motion information of thecurrent block are the same. The redundancy check may be performed on allinter-region merge candidates previously stored in the inter-regionmotion information list. Alternatively, the redundancy check may beperformed on inter-region merge candidates having an index larger than athreshold value or smaller than a threshold value among inter-regionmerge candidates previously stored in the inter-region motioninformation list.

When an inter-region merge candidate having the same motion informationas the motion information of the current block is not included, theinter-region merge candidate derived based on the current block may beadded to the inter-region motion information list (S1508). Whether theinter-region merge candidates are the same may be determined based onwhether motion information (e.g., a motion vector and/or a referencepicture index) of the inter-region merge candidates is the same.

At this point, when the maximum number of inter-region merge candidatesare already stored in the inter-region motion information list (S1506),the oldest inter-region merge candidate is deleted (S1507), and theinter-region merge candidate derived based on the current block may beadded to the inter-region motion information list (S1508).

Each of the inter-region merge candidates may be identified by an index.When an inter-region merge candidate derived from the current block isadded to the inter-region motion information list, the lowest index(e.g., 0) is assigned to the inter-region merge candidate, and indexesof the previously stored inter-region merge candidates may be increasedby 1. At this point, when the maximum number of inter-region mergecandidates are already stored in the inter-region motion informationlist, an inter-region merge candidate having the largest index isremoved.

Alternatively, when the inter-region merge candidate derived from thecurrent block is added to the inter-region motion information list, thelargest index may be assigned to the inter-region merge candidate. Forexample, when the number of inter-region merge candidates previouslystored in the inter-region motion information list is smaller than amaximum value, an index having the same value as the number ofpreviously stored inter-region merge candidates may be assigned to theinter-region merge candidate. Alternatively, when the number ofinter-region merge candidates previously stored in the inter-regionmotion information list is the same as the maximum value, an indexsubtracting 1 from the maximum value may be assigned to the inter-regionmerge candidate. In addition, an inter-region merge candidate having thesmallest index is removed, and indexes of remaining previously storedinter-region merge candidates may be decreased by 1.

FIG. 16 is a view showing an embodiment of updating an inter-regionmerge candidate list.

It is assumed that as the inter-region merge candidate derived from thecurrent block is added to the inter-region merge candidate list, thelargest index is assigned to the inter-region merge candidate. Inaddition, it is assumed that the maximum number of inter-region mergecandidates is already stored in the inter-region merge candidate list.

When the inter-region merge candidate HmvpCand[n+1] derived from thecurrent block is added to the inter-region merge candidate listHmvpCandList, the inter-region merge candidate HmvpCand[0] having thesmallest index among the previously stored inter-region merge candidatesis deleted, and the indexes of the remaining inter-region mergecandidates may be decreased by 1. In addition, the index of theinter-region merge candidate HmvpCand[n+1] derived from the currentblock may be set to a maximum value (n in the example shown in FIG. 16).

When an inter-region merge candidate the same as the inter-region mergecandidate derived based on the current block is previously stored(S1505), the inter-region merge candidate derived based on the currentblock may not be added to the inter-region motion information list(S1509).

Alternatively, as the inter-region merge candidate derived based on thecurrent block is added to the inter-region motion information list, apreviously stored inter-region merge candidate that is the same as theinter-region merge candidate may be removed. In this case, an effect thesame as newly updating the index of the previously stored inter-regionmerge candidate is obtained.

FIG. 17 is a view showing an example in which an index of a previouslystored inter-region merge candidate is updated.

When the index of a previously stored inter-region merge candidatemvCand that is the same as the inter-region merge candidate mvCandderived based on the current block is hIdx, the previously storedinter-region merge candidate is deleted, and indexes of inter-regionmerge candidates having an index larger than hIdx may be decreased by 1.For example, in the example shown in FIG. 17, it is shown thatHmvpCand[2] the same as mvCand is deleted from the inter-region motioninformation list HvmpCandList, and the indexes of HmvpCand[3] toHmvpCand[n] are decreased by 1.

In addition, the inter-region merge candidate mvCand derived based onthe current block may be added to the end of the inter-region motioninformation list.

Alternatively, the index assigned to the previously stored inter-regionmerge candidate that is the same as the inter-region merge candidatederived based on the current block may be updated. For example, theindex of the previously stored inter-region merge candidate may bechanged to a minimum value or a maximum value.

It may be set not to add motion information of blocks included in apredetermined area to the inter-region motion information list. Forexample, an inter-region merge candidate derived based on motioninformation of a block included in the merge processing area may not beadded to the inter-region motion information list. Since anencoding/decoding order is not defined for the blocks included in themerge processing area, it is inappropriate to use motion information ofany one among the blocks for inter prediction of another block.Accordingly, inter-region merge candidates derived based on the blocksincluded in the merge processing area may not be added to theinter-region motion information list.

When motion compensation prediction is performed by the unit ofsubblock, an inter-region merge candidate may be derived based on motioninformation of a representative subblock among a plurality of subblocksincluded in the current block. For example, when a subblock mergecandidate is used for the current block, an inter-region merge candidatemay be derived based on motion information of a representative subblockamong the subblocks.

Motion vectors of the subblocks may be derived in the following order.First, any one among the merge candidates included in the mergecandidate list of the current block is selected, and an initial shiftvector (shVector) may be derived based on the motion vector of theselected merge candidate. Then, a shift subblock, in which the positionof the reference sample is (xColSb, yColSb), may be derived as theinitial shift vector is added at the position (xSb, ySb) of thereference sample (e.g., the top-left sample or the sample at the center)of each subblock in the coding block. Equation 4 shows an equation forderiving a shift subblock.(xColSb,yColSb)=(xSb+shVector[0]>>4,ySb+shVector[1]>>4)  [Equation 4]

Then, the motion vector of a collocated block corresponding to thecenter position of the subblock including (xColSb, yColSb) may be set asthe motion vector of the subblock including (xSb, ySb).

The representative subblock may mean a subblock including the top-leftsample or the sample at the center of the current block.

FIG. 18 is a view showing the position of a representative subblock.

FIG. 18(a) shows an example in which the subblock positioned at thetop-left of the current block is set as the representative subblock, andFIG. 18(b) shows an example in which the subblock positioned at thecenter of the current block is set as the representative subblock. Whenmotion compensation prediction is performed by unit of subblock, aninter-region merge candidate of the current block may be derived basedon the motion vector of the subblock including the top-left sample ofthe current block or the subblock including the sample at the center ofthe current block.

It may be determined whether or not to use the current block as aninter-region merge candidate, based on the inter prediction mode of thecurrent block. For example, a block encoded/decoded based on an affinemotion model may be set to be unavailable as an inter-region mergecandidate. Accordingly, although the current block is encoded/decoded byinter prediction, when the inter prediction mode of the current block isthe affine prediction mode, the inter region motion information list maynot be updated based on the current block.

Alternatively, the inter-region merge candidate may be derived based onat least one subblock vector among the subblocks included in the blockencoded/decoded based on the affine motion model. For example, theinter-region merge candidate may be derived using a subblock positionedat the top-left, a subblock positioned at the center, or a subblockpositioned at the top-right side of the current block. Alternatively, anaverage value of subblock vectors of a plurality of subblocks may be setas the motion vector of the inter-region merge candidate.

Alternatively, the inter-region merge candidate may be derived based onan average value of affine seed vectors of the block encoded/decodedbased on the affine motion model. For example, an average of at leastone among the first affine seed vector, the second affine seed vector,and the third affine seed vector of the current block may be set as themotion vector of the inter-region merge candidate.

Alternatively, an inter-region motion information list may be configuredfor each inter prediction mode. For example, at least one among aninter-region motion information list for a block encoded/decoded byintra-block copy, an inter-region motion information list for a blockencoded/decoded based on a translational motion model, and aninter-region motion information list for a block encoded/decoded basedon an affine motion model may be defined. According to the interprediction mode of the current block, any one among a plurality ofinter-region motion information lists may be selected.

FIG. 19 is a view showing an example in which an inter-region motioninformation list is generated for each inter prediction mode.

When a block is encoded/decoded based on a non-affine motion model, aninter-region merge candidate mvCand derived based on the block may beadded to an inter-region non-affine motion information listHmvpCandList. On the other hand, when a block is encoded/decoded basedon an affine motion model, an inter-region merge candidate mvAftandderived based on the block may be added to an inter-region affine motioninformation list HmvpAfCandList.

Affine seed vectors of a block encoded/decoded based on the affinemotion model may be stored in an inter-region merge candidate derivedfrom the block. Accordingly, the inter-region merge candidate may beused as a merge candidate for deriving the affine seed vector of thecurrent block.

In addition to the inter-region motion information list described above,an additional inter-region motion information list may be defined. Inaddition to the inter-region motion information list described above(hereinafter, referred to as a first inter-region motion informationlist), a long-term motion information list (hereinafter, referred to asa second inter-region motion information list) may be defined. Here, thelong-term motion information list includes long-term merge candidates.

When both the first inter-region motion information list and the secondinter-region motion information list are empty, first, inter-regionmerge candidates may be added to the second inter-region motioninformation list. Only after the number of available inter-region mergecandidates reaches the maximum number in the second inter-region motioninformation list, inter-region merge candidates may be added to thefirst inter-region motion information list.

Alternatively, one inter-region merge candidate may be added to both thesecond inter-region motion information list and the first inter-regionmotion information list.

At this point, the second inter-region motion information list, theconfiguration of which has been completed, may not be updated any more.Alternatively, when the decoded region is greater than or equal to apredetermined ratio of the slice, the second inter-region motioninformation list may be updated. Alternatively, the second inter-regionmotion information list may be updated for every N coding tree unitlines.

On the other hand, the first inter-region motion information list may beupdated whenever a block encoded/decoded by inter prediction isgenerated. However, it may be set not to use the inter-region mergecandidate added to the second inter-region motion information list, toupdate the first inter-region motion information list.

Information for selecting any one among the first inter-region motioninformation list and the second inter-region motion information list maybe signaled through a bitstream. When the number of merge candidatesincluded in the merge candidate list is smaller than a threshold value,merge candidates included in the inter-region motion information listindicated by the information may be added to the merge candidate list.

Alternatively, an inter-region motion information list may be selectedbased on the size and shape of the current block, inter prediction mode,whether bidirectional prediction is enabled, whether motion vectorrefinement is enabled, or whether triangular partitioning is enabled.

Alternatively, although an inter-region merge candidate included in thefirst inter-region motion information list is added, when the number ofmerge candidates included in the merge candidate list is smaller thanthe maximum number of merges, the inter-region merge candidates includedin the second inter-region motion information list may be added to themerge candidate list.

FIG. 20 is a view showing an example in which an inter-region mergecandidate included in a long-term motion information list is added to amerge candidate list.

When the number of merge candidates included in the merge candidate listis smaller than the maximum number, the inter-region merge candidatesincluded in the first inter-region motion information list HmvpCandListmay be added to the merge candidate list. When the number of mergecandidates included in the merge candidate list is smaller than themaximum number although the inter-region merge candidates included inthe first inter-region motion information list are added to the mergecandidate list, the inter-region merge candidates included in thelong-term motion information list HmvpLTCandList may be added to themerge candidate list.

The inter-region merge candidate may be set to include additionalinformation, in addition to motion information. For example, for theinter-region merge candidate, a size, a shape, or partition informationof a block may be additionally stored. When the merge candidate list ofthe current block is constructed, only inter-region merge candidateshaving a size, a shape, or partition information the same as or similarto those of the current block are used among the inter-region mergecandidates, or inter-region merge candidates having a size, a shape, orpartition information the same as or similar to those of the currentblock may be added to the merge candidate list in the first place.

Alternatively, an inter-region motion information list may be generatedfor each of the size, shape, or partition information of a block. Amongthe plurality of inter-region motion information lists, a mergecandidate list of the current block may be generated by using aninter-region motion information list corresponding to the shape, size,or partition information of the current block.

When the number of merge candidates included in the merge candidate listof the current block is smaller than the threshold value, theinter-region merge candidates included in the inter-region motioninformation list may be added to the merge candidate list. The additionprocess is performed in an ascending or descending order based on theindex. For example, an inter-region merge candidate having the largestindex may be first added to the merge candidate list.

When it is desired to add an inter-region merge candidate included inthe inter-region motion information list to the merge candidate list, aredundancy check may be performed between the inter-region mergecandidate and the merge candidates previously stored in the mergecandidate list.

The redundancy check may be performed only on some of the inter-regionmerge candidates included in the inter-region motion information list.For example, the redundancy check may be performed only on inter-regionmerge candidates having an index larger than a threshold value orsmaller than a threshold value. Alternatively, the redundancy check maybe performed only on N merge candidates having the largest index or Nmerge candidates having the smallest index.

Alternatively, the redundancy check may be performed only on some of themerge candidates previously stored in the merge candidate list. Forexample, the redundancy check may be performed only on a merge candidatehaving an index larger than a threshold value or smaller than athreshold value, or on a merge candidate derived from a block at aspecific position. Here, the specific position may include at least oneamong a left neighboring block, a top neighboring block, a top-rightneighboring block, and a bottom-left neighboring block of the currentblock.

FIG. 21 is a view showing an example in which a redundancy check isperformed only on some of merge candidates.

When it is desired to add the inter-region merge candidate HmvpCand[j]to the merge candidate list, a redundancy check may be performed on theinter-region merge candidate with two merge candidatesmergeCandList[NumMerge-2] and mergeCandList[NumMerge-1] having thelargest indexes. Here, NumMerge may represent the number of spatialmerge candidates and temporal merge candidates that are available.

Unlike the example shown in the drawing, when it is desired to add aninter-region merge candidate HmvpCand[j] to the merge candidate list, aredundancy check may be performed on the inter-region merge candidatewith up to two merge candidates having the smallest index. For example,it is possible to check whether mergeCandList[0] and mergeCandList[1]are the same as HmvpCand[j]. Alternatively, a redundancy check may beperformed only on merge candidates derived at a specific position. Forexample, the redundancy check may be performed on at least one among amerge candidate derived from a neighboring block positioned on the leftside of the current block and a merge candidate derived from aneighboring block positioned on the top the current block. When a mergecandidate derived at a specific position does not exist in the mergecandidate list, an inter-region merge candidate may be added to themerge candidate list without having a redundancy check.

When a merge candidate the same as the first inter-region mergecandidate is found and a redundancy check is performed on the secondinter-region merge candidate, the redundancy check with a mergecandidate the same as the first inter-region merge candidate may beomitted.

FIG. 22 is a view showing an example in which a redundancy check isomitted for a specific merge candidate.

When it is desired to add an inter-region merge candidate HmvpCand[i]having index i to the merge candidate list, a redundancy check isperformed between the inter-region merge candidate and merge candidatespreviously stored in the merge candidate list. At this point, when amerge candidate mergeCandList[j] the same as the inter-region mergecandidate HmvpCand[i] is found, the redundancy check may be performedbetween the inter-region merge candidate HmvpCand[i−1] having index i−1and the merge candidates without adding the inter-region merge candidateHmvpCand[i] to the merge candidate list. At this point, the redundancycheck between the inter-region merge candidate HmvpCand[i−1] and themerge candidate mergeCandList[j] may be omitted.

For example, in the example shown in FIG. 22, it is determined thatHmvpCand[i] and mergeCandList[2] are the same. Accordingly, HmvpCand[i]is not added to the merge candidate list, and a redundancy check may beperformed on HmvpCand[i−1]. At this point, the redundancy check betweenHvmpCand[i−1] and mergeCandList[2] may be omitted.

When the number of merge candidates included in the merge candidate listof the current block is smaller than the threshold value, at least oneamong a pairwise merge candidate and a zero-merge candidate may befurther included, in addition to the inter-region merge candidate. Thepairwise merge candidate means a merge candidate having an average valueof motion vectors of two or more merge candidates as a motion vector,and the zero-merge candidate means a merge candidate having a motionvector of 0.

A merge candidate may be added to the merge candidate list of thecurrent block in the following order.

Spatial merge candidate-Temporal merge candidate-Inter-region mergecandidate-(Inter-region affine merge candidate)-Pairwise mergecandidate-Zero-merge candidate

The spatial merge candidate means a merge candidate derived from atleast one among a neighboring block and a non-neighboring block, and thetemporal merge candidate means a merge candidate derived from a previousreference picture. The inter-region affine merge candidate represents aninter-region merge candidate derived from a block encoded/decoded withan affine motion model.

The inter-region motion information list may also be used in the motionvector prediction mode. For example, when the number of motion vectorprediction candidates included in a motion vector prediction candidatelist of the current block is smaller than a threshold value, aninter-region merge candidate included in the inter-region motioninformation list may be set as a motion vector prediction candidate forthe current block. Specifically, the motion vector of the inter-regionmerge candidate may be set as a motion vector prediction candidate.

When any one among the motion vector prediction candidates included inthe motion vector prediction candidate list of the current block isselected, the selected candidate may be set as the motion vectorpredictor of the current block. Thereafter, after a motion vectorresidual coefficient of the current block is decoded, a motion vector ofthe current block may be obtained by adding the motion vector predictorand the motion vector residual coefficient.

The motion vector prediction candidate list of the current block may beconfigured in the following order.

Spatial motion vector prediction candidate-Temporal motion vectorprediction candidate-Inter-region merge candidate-(Inter-region affinemerge candidate)-Zero-motion vector prediction candidate

The spatial motion vector prediction candidate means a motion vectorprediction candidate derived from at least one among a neighboring blockand a non-neighboring block, and the temporal motion vector predictioncandidate means a motion vector prediction candidate derived from aprevious reference picture. The inter-region affine merge candidaterepresents an inter-region motion vector prediction candidate derivedfrom a block encoded/decoded with the affine motion model. Thezero-motion vector prediction candidate represents a candidate having amotion vector value of 0.

A coding block may be partitioned into a plurality of prediction units,and prediction may be performed on each of the partitioned predictionunits. Here, a prediction unit represents a basic unit for performingthe prediction.

A coding block may be partitioned using at least one among a verticalline, a horizontal line, an oblique line, and a diagonal line.Information for determining at least one among the number, the angles,and the positions of lines partitioning a coding block may be signaledthrough a bitstream. For example, information indicating any one amongpartition type candidates of a coding block may be signaled through abitstream, or information specifying any one among a plurality of linecandidates for partitioning a coding block may be signaled through abitstream. Alternatively, information for determining the number ortypes of line candidates partitioning a coding block may be signaledthrough the bitstream. For example, whether an oblique line having anangle greater than that of a diagonal line and/or an oblique line havingan angle smaller than that of a diagonal line may be used as a linecandidate may be determined using a 1-bit flag.

Alternatively, at least one among the number, the angles, and thepositions of lines partitioning a coding block may be adaptivelydetermined based on at least one among the intra prediction mode of thecoding block, the inter prediction mode of the coding block, theposition of an available merge candidate of the coding block, and apartitioning pattern of a neighboring block.

When a coding block is partitioned into a plurality of prediction units,intra prediction or inter prediction may be performed on each of thepartitioned prediction units.

FIG. 23 is a view showing examples of applying partitioning to a codingblock to obtain a plurality of prediction units using a diagonal line.

As shown in the examples of FIGS. 23(a) and 23(b), a coding block may bepartitioned into two triangular prediction units using a diagonal line.

In FIGS. 23(a) and 23(b), it is shown that a coding block is partitionedinto two prediction units using a diagonal line connecting two verticesof the coding block. However, the coding block may be partitioned intotwo prediction units using an oblique line, at least one end of whichdoes not pass through a vertex of the coding block.

FIG. 24 is a view showing examples of applying partitioning to a codingblock to obtain two prediction units.

As shown in the examples of FIGS. 24(a) and 24(b), a coding block may bepartitioned into two prediction units using an oblique line, both endsof which are in contact with the top boundary and the bottom boundary ofthe coding block, respectively.

Alternatively, as shown in the examples of FIGS. 24(c) and 24(d), acoding block may be partitioned into two prediction units using anoblique line, both ends of which are in contact with the left boundaryand the right boundary of the coding block, respectively.

Alternatively, a coding block may be partitioned into two predictionblocks of different size. For example, a coding block may be partitionedinto two prediction units of different size by setting an oblique linepartitioning the coding block to contact two boundary surfaces that formone vertex.

FIG. 25 is a view showing examples of partitioning a coding block into aplurality of prediction blocks of different size.

As shown in the examples of FIGS. 25(a) and 25(b), as a diagonal lineconnecting the top-left and bottom-right corners of the coding block isset to pass through the left boundary, the right boundary, the topboundary, or the bottom boundary, instead of passing through thetop-left corner or the bottom-right corner of the coding block, thecoding block may be partitioned into two prediction units havingdifferent sizes.

Alternatively, as shown in the examples of FIGS. 25(c) and 25(d), as adiagonal line connecting the top-right and bottom-left corners of thecoding block is set to pass through the left boundary, the rightboundary, the top boundary, or the bottom boundary, instead of passingthrough the top-left corner or the bottom-right corner of the codingblock, the coding block may be partitioned into two prediction unitshaving different sizes.

Each of the prediction units generated by partitioning a coding blockwill be referred to as an ‘N-th prediction unit’. For example, in theexamples shown in FIGS. 23 to 25, PU1 may be defined as a firstprediction unit, and PU2 may be defined as a second prediction unit. Thefirst prediction unit means a prediction unit including a samplepositioned at the bottom left or a sample positioned at the top left inthe coding block, and the second prediction unit means a prediction unitincluding a sample positioned at the top right or a sample positioned atthe bottom right in the coding block.

Contrarily, a prediction unit including a sample positioned at the topright or a sample positioned at the bottom right in the coding block maybe defined as a first prediction unit, and a prediction unit including asample positioned at the bottom left or a sample positioned at the topleft in the coding block may be defined as a second prediction unit.

Embodiments below are described focusing on examples of partitioning acoding block using a diagonal line. Particularly, partitioning a codingblock into two prediction units using a diagonal line is referred to asdiagonal partitioning or triangular partitioning, and a prediction unitgenerated based on the diagonal partitioning is referred to as atriangular prediction unit. However, it is also possible to apply theembodiments described below to the examples of partitioning a codingblock using an oblique line of an angle different from that of avertical line, a horizontal line, or a diagonal line.

Whether or not to apply the diagonal partitioning to a coding block maybe determined based on at least one among a slice type, the maximumnumber of merge candidates that the merge candidate list may include,the size of the coding block, the shape of the coding block, theprediction encoding mode of the coding block, and the partitioningpattern of the parent node.

For example, whether or not to apply the diagonal partitioning to acoding block may be determined based on whether the current slice istype B. Diagonal partitioning may be allowed only when the current sliceis type B.

Alternatively, whether or not to apply the diagonal partitioning to acoding block may be determined based on whether the maximum number ofmerge candidates included in the merge candidate list is two or more.Diagonal partitioning may be allowed only when the maximum number ofmerge candidates included in the merge candidate list is two or more.

Alternatively, when at least one among the width and the height isgreater than 64 in hardware implementation, there is a problem in that adata processing unit of a 64×64 size is redundantly accessed.Accordingly, when at least one among the width and the height of thecoding block is greater than a threshold value, partitioning a codingblock into a plurality of prediction blocks may not be allowed. Forexample, when at least one among the width and the height of a codingblock is greater than 64 (e.g., when at least one among the width andthe height is 128), diagonal partitioning may not be used.

Alternatively, diagonal partitioning may not be allowed for a codingblock of which the number of samples is larger than a threshold value,considering the maximum number of samples that can be simultaneouslyprocessed in hardware implementation. For example, diagonal partitioningmay not be allowed for a coding tree block of which the number ofsamples is larger than 4,096.

Alternatively, diagonal partitioning may not be allowed for a codingblock of which the number of samples included in the coding block issmaller than a threshold value. For example, it may be set not to applythe diagonal partitioning to a coding block when the number of samplesincluded in the coding block is smaller than 64.

Alternatively, whether or not to apply the diagonal partitioning to acoding block may be determined based on whether the width to heightratio of the coding block is lower than a first threshold value orwhether the width to height ratio of the coding block is higher than asecond threshold value. Here, the width to height ratio whRatio of thecoding block may be determined as a ratio of the width CbW to the heightCbH of the coding block as shown in Equation 5.whRatio=CbW/CbH  [Equation 5]

The second threshold value may be an inverse number of the firstthreshold value. For example, when the first threshold value is k, thesecond threshold value may be 1/k.

The diagonal partitioning may be applied to a coding block only when thewidth to height ratio of the coding block is between the first thresholdvalue and the second threshold value.

Alternatively, triangular partitioning may be used only when the widthto height ratio of the coding block is lower than the first thresholdvalue or higher than the second threshold value. For example, when thefirst threshold value is 16, diagonal partitioning may not be allowedfor a coding block of a 64×4 or 4×64 size.

Alternatively, whether or not to allow the diagonal partitioning may bedetermined based on the partitioning pattern of the parent node. Forexample, when a parent node coding block is partitioned based onquad-tree partitioning, diagonal partitioning may be applied to a leafnode coding block. On the other hand, it may be set not to allow thediagonal partitioning to the leaf node coding block when the parent nodecoding block is partitioned based on binary tree or ternary treepartitioning.

Alternatively, whether or not to allow the diagonal partitioning may bedetermined based on the prediction encoding mode of a coding block. Forexample, the diagonal partitioning may be allowed only when the codingblock is encoded by intra prediction, when the coding block is encodedby inter prediction, or when the coding block is encoded by a predefinedinter prediction mode. Here, the predefined inter prediction mode mayrepresent at least one among a merge mode, a motion vector predictionmode, an affine merge mode, and an affine motion vector prediction mode.

Alternatively, whether or not to allow the diagonal partitioning may bedetermined based on the size of a parallel processing region. Forexample, when the size of a coding block is larger than the size of aparallel processing region, diagonal partitioning may not be used.

Whether or not to apply the diagonal partitioning to a coding block maybe determined considering two or more of the conditions listed above.

As another example, information indicating whether or not to apply thediagonal partitioning to a coding block may be signaled through abitstream. The information may be signaled at a sequence, picture,slice, or block level. For example, flag triangle_partition_flagindicating whether triangular partitioning is applied to a coding blockmay be signaled at a coding block level.

When it is determined to apply the diagonal partitioning to a codingblock, information indicating the number of lines partitioning thecoding block or the positions of the lines may be signaled through abitstream.

For example, when a coding block is partitioned by a diagonal line,information indicating the direction of the diagonal line partitioningthe coding block may be signaled through a bitstream. For example, flagtriangle_partition_type_flag indicating the direction of the diagonalline may be signaled through a bitstream. The flag indicates whether thecoding block is partitioned by a diagonal line connecting the top-leftcorner and the bottom-right corner or whether the coding block ispartitioned by a diagonal line connecting the top-right corner and thebottom-left corner. Partitioning a coding block by a diagonal lineconnecting the top-left corner and the bottom-right corner may bereferred to as a left triangular partition type, and partitioning acoding block by a diagonal line connecting the top-right corner and thebottom-left corner may be referred to as a right triangular partitiontype. For example, when the value of the flag is 0, it may indicate thatthe partition type of the coding block is the left triangular partitiontype, and when the value of the flag is 1, it may indicate that thepartition type of the coding block is the right triangular partitiontype.

Additionally, information indicating whether the prediction units havethe same size or information indicating the position of a diagonal linefor partitioning the coding block may be signaled through a bitstream.For example, when the information indicating the sizes of the predictionunits indicates that the sizes of the prediction units are the same,encoding of the information indicating the position of the diagonal isomitted, and the coding block may be partitioned into two predictionunits using a diagonal line passing through two vertices of the codingblock. On the other hand, when the information indicating the sizes ofthe prediction units indicates that the sizes of the prediction unitsare not the same, the position of the diagonal line partitioning thecoding block may be determined based on the information indicating theposition of the diagonal line. For example, when the left triangularpartition type is applied to a coding block, the position informationmay indicate whether the diagonal line is in contact with the leftboundary and the bottom boundary or the top boundary and the rightboundary of the coding block. Alternatively, when the right triangularpartition type is applied to a coding block, the position informationmay indicate whether the diagonal line is in contact with the rightboundary and the bottom boundary or the top boundary and the leftboundary of the coding block.

Information indicating the partition type of a coding block may besignaled at a coding block level. Accordingly, the partition type may bedetermined for each coding block to which the diagonal partitioning isapplied.

As another example, information indicating the partition type may besignaled for a sequence, a picture, a slice, a tile, or a coding treeunit. In this case, partition types of coding blocks to which thediagonal partitioning is applied in a sequence, a picture, a slice, atile, or a coding tree unit may be set to be the same.

Alternatively, information for determining the partition type may beencoded and signaled for the first coding unit to which the diagonalpartitioning is applied in the coding tree unit, and the second andsubsequent coding units to which the diagonal partitioning is appliedmay be set to use a partition type the same as that of the first codingunit.

As another example, the partition type of a coding block may bedetermined based on the partition type of a neighboring block. Here, theneighboring block may include at least one among a neighboring blockadjacent to the top-left corner of the coding block, a neighboring blockadjacent to the top-right corner, a neighboring block adjacent to thebottom-left corner, a neighboring block positioned on the top, and aneighboring block positioned on the left side. For example, thepartition type of the current block may be set to be the same as thepartition type of a neighboring block. Alternatively, the partition typeof the current block may be determined based on whether the lefttriangular partition type is applied to the top-left neighboring blockor whether the right triangular partition type is applied to thetop-right neighboring block or the bottom-left neighboring block.

In order to perform motion prediction compensation on a first triangularprediction unit and a second triangular prediction unit, motioninformation of each of the first triangular prediction unit and thesecond triangular prediction unit may be derived. At this point, themotion information of the first triangular prediction unit and thesecond triangular prediction unit may be derived from merge candidatesincluded in the merge candidate list. To distinguish a general mergecandidate list from a merge candidate list used for deriving the motioninformation of the triangular prediction units, the merge candidate listfor deriving the motion information of the triangular prediction unitsis referred to as a triangular merge candidate list, and a mergecandidate included in the triangular merge candidate list will bereferred to as a triangular merge candidate. However, using the methodof deriving a merge candidate and the method of constructing a mergecandidate list described above for the sake of the triangular mergecandidates and the method of constructing the triangular merge candidatelist is also included in the spirit of the present disclosure.

Information for determining the maximum number of triangular mergecandidates that the triangular merge candidate list may include may besignaled through a bitstream. The information may indicate a differencebetween the maximum number of merge candidates that the merge candidatelist may include and the maximum number of triangular merge candidatesthat the triangular merge candidate list may include.

The triangular merge candidates may be derived from a spatiallyneighboring block and a temporally neighboring block of a coding block.

FIG. 26 is a view showing neighboring blocks used for deriving atriangular merge candidate.

A triangular merge candidate may be derived using at least one among aneighboring block positioned on the top of a coding block, a neighboringblock positioned on the left side of the coding block, and a collocatedblock included in a picture different from the coding block. The topneighboring block may include at least one among a block including asample (xCb+CbW−1, yCb−1) positioned on the top of the coding block, ablock including a sample (xCb+CbW, yCb−1) positioned on the top of thecoding block, and a block including a sample (xCb−1, yCb−1) positionedon the top of the coding block. The left neighboring block may includeat least one among a block including a sample (xCb−1, yCb+CbH−1)positioned on the left side of the coding block and a block including asample (xCb−1, yCb+CbH) positioned on the left side of the coding block.The collocated block may be determined as any one among a blockincluding a sample (xCb+CbW, yCb+CbH) adjacent to the top-right cornerof the coding block and a block including a sample (xCb/2, yCb/2)positioned at the center of the coding block, in a collocated picture.

The neighboring blocks may be searched in a predefined order, andtriangular merge candidates may be constructed as a triangular mergecandidate list according to a predefined order. For example, thetriangular merge candidate list may be constructed by searching thetriangular merge candidates in the order of B1, A1, B0, A0, C0, B2 andC1.

Motion information of the triangular prediction units may be derivedbased on the triangular merge candidate list. That is, the triangularprediction units may share one triangular merge candidate list.

In order to derive motion information of the triangular merge unit,information for specifying at least one among the triangular mergecandidates included in the triangular merge candidate list may besignaled through a bitstream. For example, index informationmerge_triangle_idx for specifying at least one among the triangularmerge candidates may be signaled through a bitstream.

The index information may specify a combination of a merge candidate ofthe first triangular prediction unit and a merge candidate of the secondtriangular prediction unit. For example, Table 1 shows an example of acombination of merge candidates according to index informationmerge_triangle_idx.

TABLE 1 merge_triangle_idx 0 1 2 3 4 5 6 7 8 First prediction unit 1 0 00 2 0 0 1 3 Second prediction unit 0 1 2 1 0 3 4 0 0 merge_triangle_idx9 10 11 12 13 14 15 16 17 First prediction unit 4 0 1 1 0 0 1 1 1 Secondprediction unit 0 2 2 9 4 3 3 4 4 merge_triangle_idx 18 19 20 21 22 2324 25 26 First triangular 1 2 2 2 4 3 3 3 4 prediction unit Secondtriangular 3 1 0 1 3 0 2 4 0 prediction unit merge_triangle_idx 27 28 2930 31 32 33 34 35 First triangular 3 9 4 4 2 4 3 4 3 prediction unitSecond triangular 1 3 1 1 3 2 2 3 1 prediction unit merge_triangle_idx36 37 38 39 First triangular 2 7 4 3 prediction unit Second triangular 44 4 prediction unit

When the value of index information merge_triangle_idx is 1, itindicates that the motion information of the first triangular predictionunit is derived from a merge candidate having an index of 1, and themotion information of the second triangular prediction unit is derivedfrom a merge candidate having an index of 0. A triangular mergecandidate for deriving motion information of the first triangularprediction unit and a triangular merge candidate for deriving motioninformation of the second triangular prediction unit may be determinedthrough index information merge_triangle_idx.

A partition type of a coding block to which the diagonal partitioning isapplied may be determined based on the index information. That is, theindex information may specify a combination of a merge candidate of thefirst triangular prediction unit, a merge candidate of the secondtriangular prediction unit, and a partitioning direction of the codingblock. When a partition type of the coding block is determined based onthe index information, information triangle_partition_type_flagindicating the direction of a diagonal line partitioning the codingblock may not be coded. Table 2 expresses partition types of a codingblock with respect to index information merge_triangle_idx.

TABLE 2 merge_triangle_idx 0 1 2 3 4 5 6 7 8 TriangleDir 0 1 1 0 0 1 1 10 merge_triangle_idx 9 10 11 12 13 14 15 16 17 TriangleDir 0 0 0 1 0 0 00 1 merge_triangle_idx 18 19 20 21 22 23 24 25 26 TriangleDir 1 1 1 0 01 1 1 1 merge_triangle_idx 27 28 29 30 31 32 33 34 35 TriangleDir 1 1 10 0 1 0 1 0 merge_triangle_idx 36 37 38 39 TriangleDir 0 1 0 0

When variable TriangleDir is 0, it indicates that the left trianglepartition type is applied to the coding block, and when variableTriangleDir is 1, it indicates that the right triangle partition type isapplied to the coding block. By combining Table 1 and Table 2, it may beset to specify a combination of the merge candidate of the firsttriangular prediction unit, the merge candidate of the second triangularprediction unit, and the partitioning direction of the coding block byindex information merge_triangle_idx.

As another example, index information only for any one among the firsttriangular prediction unit and the second triangular prediction unit maybe signaled, and an index of a triangular merge candidate for the otherone among the first triangular prediction unit and the second triangularprediction unit may be determined based on the index information. Forexample, a triangular merge candidate of the first triangular predictionunit may be determined based on index information merge_triangle_idxindicating an index of any one among the triangular merge candidates. Inaddition, a triangular merge candidate of the second triangularprediction unit may be specified based on merge_triangle_idx. Forexample, the triangular merge candidate of the second triangularprediction unit may be derived by adding or subtracting an offset to orfrom index information merge_triangle_idx. The offset may be an integersuch as 1 or 2. For example, a triangular merge candidate having a valueobtained by adding 1 to merge_traingle_idx as an index may be determinedas the triangular merge candidate of the second triangular predictionunit. When merge_triangle_idx indicates a triangular merge candidatehaving the largest index value among the triangular merge candidates,motion information of the second triangular prediction unit may bederived from a triangular merge candidate having an index of 0 or atriangular merge candidate having a value obtained by subtracting 1 frommerge_triangle_idx as an index.

Alternatively, motion information of the second triangular predictionunit may be derived from a triangular merge candidate having a referencepicture the same as that of the triangular merge candidate of the firsttriangular prediction unit specified by the index information. Here, thetriangular merge candidate having a reference picture the same as thatof the triangular merge candidate of the first triangular predictionunit may indicate a triangular merge candidate having at least one amongL0 reference picture and L1 reference picture the same as those of thetriangular merge candidate of the first triangular prediction unit. Whenthere is a plurality of triangular merge candidates having a referencepicture the same as that of the triangular merge candidate of the firsttriangular prediction unit, at least one among the triangular mergecandidates may be selected based on whether the merge candidate includesbidirectional motion information or a difference value between the indexof the merge candidate and the index information.

As another example, index information may be signaled for each of thefirst triangular prediction unit and the second triangular predictionunit. For example, first index information 1st_merge_idx for determininga triangular merge candidate of the first triangular prediction unit andsecond index information 2nd_merge_idx for determining a triangularmerge candidate of the second triangular prediction unit may be signaledthrough a bitstream. The motion information of the first triangularprediction unit may be derived from the triangular merge candidatedetermined based on first index information 1st_merge_idx, and themotion information of the second triangular prediction unit may bederived from the triangular merge candidate determined based on secondindex information 2nd_merge_idx.

First index information 1st_merge_idx may indicate an index of any oneamong the triangular merge candidates included in the triangular mergecandidate list. The triangular merge candidate of the first triangularprediction unit may be determined as a triangular merge candidateindicated by first index information 1st_merge_idx.

The triangular merge candidate indicated by first index information1st_merge_idx may be set not to be used as a triangular merge candidateof the second triangular prediction unit. Accordingly, second indexinformation 2nd_merge_idx of the second triangular prediction unit mayindicate an index of any one among the remaining triangular mergecandidates excluding the triangular merge candidate indicated by thefirst index information. When the value of second index information2nd_merge_idx is smaller than the value of first index information1st_merge_idx, the triangular merge candidate of the second triangularprediction unit may be determined as a triangular merge candidate havingthe index information indicated by second index information2nd_merge_idx. On the other hand, when the value of second indexinformation 2nd_merge_idx is equal to or larger than the value of firstindex information 1st_merge_idx, the triangular merge candidate of thesecond triangular prediction unit may be determined as a triangularmerge candidate having a value obtained by adding 1 to the value ofsecond index information 2nd_merge_idx as an index.

Alternatively, whether or not to signal the second index information maybe determined according to the number of triangular merge candidatesincluded in the triangular merge candidate list. For example, when themaximum number of triangular merge candidates that the triangular mergecandidate list may include does not exceed 2, signaling of the secondindex information may be omitted. When signaling of the second indexinformation is omitted, a second triangular merge candidate may bederived by adding or subtracting an offset to or from the first indexinformation. For example, when the maximum number of triangular mergecandidates that the triangular merge candidate list may include is 2 andthe first index information indicates index 0, the second triangularmerge candidate may be derived by adding 1 to the first indexinformation. Alternatively, when the maximum number of triangular mergecandidates that the triangular merge candidate list may include is 2 andthe first index information indicates 1, the second triangular mergecandidate may be derived by subtracting 1 from the first indexinformation.

Alternatively, when signaling of the second index information isomitted, the second index information may be set to a default value.Here, the default value may be 0. The second triangular merge candidatemay be derived by comparing the first index information and the secondindex information. For example, when the second index information issmaller than the first index information, a merge candidate having index0 may be set as the second triangular merge candidate, and when thesecond index information is equal to or greater than the first indexinformation, a merge candidate having index 1 may be set as the secondtriangular merge candidate.

When the triangular merge candidate has unidirectional motioninformation, the unidirectional motion information of the triangularmerge candidate may be set as motion information of the triangularprediction unit. On the other hand, when the triangular merge candidatehas bidirectional motion information, only one among L0 motioninformation and L1 motion information may be set as motion informationof the triangular prediction unit. Which one among L0 motion informationand L1 motion information will be taken may be determined based on theindex of the triangular merge candidate or motion information of anothertriangular prediction unit.

For example, when the index of the triangular merge candidate is an evennumber, L0 motion information of the triangular prediction unit may beset to 0, and L1 motion information of the triangular merge candidatemay be set as L1 motion information of the triangular prediction unit.On the other hand, when the index of the triangular merge candidate isan odd number, L1 motion information of the triangular prediction unitmay be set to 0, and L0 motion information of the triangular mergecandidate may be set to 0. Contrarily, when the index of the triangularmerge candidate is an even number, L0 motion information of thetriangular merge candidate may be set as L0 motion information of thetriangular prediction unit, and when the index of the triangular mergecandidate is an odd number, L1 motion information of the triangularmerge candidate may be set as L1 motion information of the triangularprediction unit. Alternatively, when the triangular merge candidate isan even number for the first triangular prediction unit, L0 motioninformation of the triangular merge candidate may be set as L0 motioninformation of the first triangular prediction unit, whereas when thetriangular merge candidate is an odd number for the second triangularprediction unit, L1 motion information of the triangular merge candidatemay be set as L1 motion information of the second triangular predictionunit.

Alternatively, when the first triangular prediction unit has L0 motioninformation, L0 motion information of the second triangular predictionunit may be set to 0, and L1 motion information of the triangular mergecandidate may be set as L1 motion information of the second triangularprediction unit. On the other hand, when the first triangular predictionunit has L1 motion information, L1 motion information of the secondtriangular prediction unit may be set to 0, and L0 motion information ofthe triangular merge candidate may be set as L0 motion information ofthe second triangular prediction unit.

A triangular merge candidate list for deriving motion information of thefirst triangular prediction unit and a triangular merge candidate listfor deriving motion information of the second triangular prediction unitmay be set differently.

For example, when a triangular merge candidate for deriving motioninformation of the first triangular prediction unit in the triangularmerge candidate list is specified based on the index information for thefirst triangular prediction unit, motion information of the secondtriangular prediction unit may be derived using the triangular mergecandidate list including the remaining triangular merge candidatesexcluding the triangular merge candidate indicated by the indexinformation. Specifically, the motion information of the secondtriangular prediction unit may be derived from any one among theremaining triangular merge candidates.

Accordingly, the maximum number of triangular merge candidates that thetriangular merge candidate list of the first triangular prediction unitincludes and the maximum number of triangular merge candidates that thetriangular merge candidate list of the second triangular prediction unitincludes may be different. For example, when the triangular mergecandidate list of the first triangular prediction unit includes M mergecandidates, the triangular merge candidate list of the second triangularprediction unit may include M−1 merge candidates excluding thetriangular merge candidate indicated by the index information of thefirst triangular prediction unit.

As another example, a merge candidate of each triangular prediction unitis derived based on neighboring blocks adjacent to a coding block, andavailability of the neighboring blocks may be determined considering theshape or the position of the triangular prediction unit.

FIG. 27 is a view for describing examples of determining availability ofa neighboring block for each triangular prediction unit.

A neighboring block not adjacent to the first triangular prediction unitmay be set as unavailable for the first triangular prediction unit, anda neighboring block not adjacent to the second triangular predictionunit may be set as unavailable for the second triangular predictionunit.

For example, as shown in the example of FIG. 27(a), when the lefttriangular partition type is applied to a coding block, it may bedetermined that blocks A1, A0 and A2 adjacent to the first triangularprediction unit among the neighboring blocks adjacent to the codingblock are available for the first triangular prediction unit, whereasblocks B0 and B1 are unavailable for the first triangular predictionunit. Accordingly, the triangular merge candidate list for the firsttriangular prediction unit may include triangular merge candidatesderived from blocks A1, A0 and A2 and may not include triangular mergecandidates derived from blocks B0 and B1.

As shown in the example of FIG. 27(b), when the left triangularpartition type is applied to a coding block, it may be determined thatblocks B0 and B1 adjacent to the second triangular prediction unit areavailable for the second triangular prediction unit, whereas blocks A1,A0 and A2 are unavailable for the second triangular prediction unit.Accordingly, the triangular merge candidate list for the secondtriangular prediction unit may include triangular merge candidatesderived from blocks B0 and B1 and may not include triangular mergecandidates derived from blocks A1, A0 and A2.

Accordingly, the number of triangular merge candidates or the range oftriangular merge candidates that the triangular prediction unit may usemay be determined based on at least one among the position of thetriangular prediction unit or the partition type of the coding block.

As another example, the merge mode may be applied to only one among thefirst triangular prediction unit and the second triangular predictionunit. In addition, the motion information of the other one among thefirst triangular prediction unit and the second triangular predictionunit may be set to be the same as the motion information of thetriangular prediction unit to which the merge mode is applied, or may bederived by refining the motion information of the triangular predictionunit to which the merge mode is applied.

For example, a motion vector and a reference picture index of the firsttriangular prediction unit may be derived based on a triangular mergecandidate, and a motion vector of the second triangular prediction unitmay be derived by refining the motion vector of the first triangularprediction unit. For example, the motion vector of the second triangularprediction unit may be derived by adding or subtracting a refine motionvector {Rx, Ry} to or from the motion vector {mvD1LXx, mvD1LXy} of thefirst triangular prediction unit. The reference picture index of thesecond triangular prediction unit may be set to be the same as thereference picture index of the first triangular prediction unit.

Information for determining a refine motion vector indicating thedifference between the motion vector of the first triangular predictionunit and the motion vector of the second triangular prediction unit maybe signaled through a bitstream. The information may include at leastone among information indicating the size of the refine motion vectorand information indicating the sign of the refine motion vector.

Alternatively, the sign of the refine motion vector may be derived basedon at least one among the position of the triangular prediction unit,the index of the triangular prediction unit, and the partition typeapplied to the coding block.

As another example, the motion vector and the reference picture index ofany one among the first triangular prediction unit and the secondtriangular prediction unit may be signaled. The motion vector of theother one among the first triangular prediction unit and the secondtriangular prediction unit may be derived by refining the signaledmotion vector.

For example, the motion vector and the reference picture index of thefirst triangular prediction unit may be determined based on informationsignaled from a bitstream. In addition, the motion vector of the secondtriangular prediction unit may be derived by refining the motion vectorof the first triangular prediction unit. For example, the motion vectorof the second triangular prediction unit may be derived by adding orsubtracting a refine motion vector {Rx, Ry} to or from the motion vector{mvD1LXx, mvD1LXy} of the first triangular prediction unit. Thereference picture index of the second triangular prediction unit may beset to be the same as the reference picture index of the firsttriangular prediction unit.

Motion prediction compensation prediction for each coding block may beperformed based on the motion information of the first triangularprediction unit and the motion information of the second triangularprediction unit. At this point, degradation of video quality may occurat the boundary between the first triangular prediction unit and thesecond triangular prediction unit. For example, continuity of videoquality may be degraded in the neighborhood of an edge existing at theboundary between the first triangular prediction unit and the secondtriangular prediction unit. In order to reduce the degradation of videoquality at the boundary, a prediction sample may be derived through asmoothing filter or a weighted prediction.

The prediction samples in a coding block to which diagonal partitioningis applied may be derived based on a weighted sum operation of a firstprediction sample obtained based on the motion information of the firsttriangular prediction unit and a second prediction sample obtained basedon the motion information of the second triangular prediction unit.Alternatively, a prediction sample of the first triangular predictionunit is derived from a first prediction block determined based on themotion information of the first triangular prediction unit, and aprediction sample of the second triangular prediction unit is derivedfrom a second prediction block determined based on the motioninformation of the second triangular prediction unit, and a predictionsample positioned at the boundary region of the first triangularprediction unit and the second triangular prediction unit may be derivedbased on a weighted sum operation of the first prediction sampleincluded in the first prediction block and the second prediction sampleincluded in the second prediction block. For example, Equation 6 showsan example of deriving prediction samples of the first triangularprediction unit and the second triangular prediction unit.P(x,y)=w1*P1(x,y)+(1−w1)*P2(x,y)  [Equation 6]

In Equation 6, P1 denotes a first prediction sample, and P2 denotes asecond prediction sample. w1 denotes a weighting value applied to thefirst prediction sample, and (1−w1) denotes a weighting value applied tothe second prediction sample. As shown in the example of Equation 6, theweighting value applied to the second prediction sample may be derivedby subtracting the weighting value applied to the first predictionsample from a constant value.

When the left triangular partition type is applied to a coding block,the boundary region may include prediction samples of which the x-axiscoordinate and the y-axis coordinate are the same. On the other hand,when the right triangular partition type is applied to a coding block,the boundary region may include prediction samples of which the sum ofthe x-axis coordinate and the y-axis coordinate is larger than or equalto a first threshold value and smaller than a second threshold value.

A size of the boundary region may be determined based on at least oneamong the size of the coding block, the shape of the coding block,motion information of the triangular prediction units, a value ofdifference between the motion vectors of the triangular predictionunits, an output order of reference pictures, and a value of differencebetween the first prediction sample and the second prediction sample atthe diagonal boundary.

FIGS. 28 and 29 are views showing examples of deriving a predictionsample based on a weighted sum operation of a first prediction sampleand a second prediction sample. FIG. 28 shows an example of applying theleft triangular partition type to a coding block, and FIG. 29 shows anexample of applying the right triangular partition type to a codingblock. In addition, FIGS. 28(a) and 29(a) are views showing predictionpatterns for a luma component, and FIGS. 28(b) and 29(b) are viewsshowing prediction patterns for a chroma component.

In the drawings, the numbers marked on the prediction samples positionednear the boundary between the first prediction unit and the secondprediction unit indicate weighting values applied to the firstprediction sample. For example, when a number marked on a predictionsample is N, the prediction sample may be derived by applying aweighting value of N/8 to the first prediction sample and applying aweighting value of (1−(N/8)) to the second prediction sample.

In a non-boundary region, the first prediction sample or the secondprediction sample may be determined as a prediction sample. Referring tothe example of FIG. 28, in a region belonging to the first triangularprediction unit among the regions in which the absolute value of thedifference between the x-axis coordinate and the y-axis coordinate islarger than a threshold value, the first prediction sample derived basedon the motion information of the first triangular prediction unit may bedetermined as a prediction sample. On the other hand, in a regionbelonging to the second triangular prediction unit among the regions inwhich the value of difference between the x-axis coordinate and they-axis coordinate is larger than a threshold value, the secondprediction sample derived based on the motion information of the secondtriangular prediction unit may be determined as a prediction sample.

Referring to the example of FIG. 29, in a region in which the sum of thex-axis coordinate and the y-axis coordinate is smaller than a firstthreshold value, the first prediction sample derived based on the motioninformation of the first triangular prediction unit may be determined asa prediction sample. On the other hand, in a region in which the sum ofthe x-axis coordinate and the y-axis coordinate is larger than a secondthreshold value, the second prediction sample derived based on themotion information of the second triangular prediction unit may bedetermined as a prediction sample.

A threshold value for determining a non-boundary region may bedetermined based on at least one among the size of a coding block, theshape of the coding block, and a color component. For example, when thethreshold value for a luma component is set to N, the threshold valuefor a chroma component may be set to N/2.

The prediction samples included in the boundary region may be derivedbased on a weighted sum operation of the first prediction sample and thesecond prediction sample. At this point, the weighting values applied tothe first prediction sample and the second prediction sample may bedetermined based on at least one among the position of a predictionsample, the size of a coding block, the shape of the coding block, and acolor component.

For example, as shown in the example of FIG. 28(a), prediction samplesat the position of the same x-axis coordinate and y-axis coordinate maybe derived by applying the same weighting value to the first predictionsample and the second prediction sample. Prediction samples of which theabsolute value of the difference between the x-axis coordinate and they-axis coordinate is 1 may be derived by setting the weighting valueratio applied to the first prediction sample and the second predictionsample to (3:1) or (1:3). In addition, prediction samples of which theabsolute value of the difference of the x-axis coordinate and the y-axiscoordinate is 2 may be derived by setting the weighting value ratioapplied to the first prediction sample and the second prediction sampleto (7:1) or (1:7).

Alternatively, as shown in the example of FIG. 28(b), prediction samplesat the position of the same x-axis coordinate and y-axis coordinate maybe derived by applying the same weighting value to the first predictionsample and the second prediction sample, and prediction samples of whichthe absolute value of the difference between the x-axis coordinate andthe y-axis coordinate is 1 may be derived by setting the weighting valueratio applied to the first prediction sample and the second predictionsample to (7:1) or (1:7).

For example, as shown in the example of FIG. 29(a), prediction samplesof which the sum of the x-axis coordinate and the y-axis coordinate issmaller than the width or the height of a coding block by 1 may bederived by applying the same weighting value to the first predictionsample and the second prediction sample. Prediction samples of which thesum of the x-axis coordinate and the y-axis coordinate is equal to orsmaller than the width or the height of the coding block by 2 may bederived by setting the weighting value ratio applied to the firstprediction sample and the second prediction sample to (3:1) or (1: 3).Predicted samples of which the sum of the x-axis coordinates and they-axis coordinates is greater than or smaller than the width or theheight of the coding block by 1 or 3 may be derived by setting theweighting value ratio applied to the first prediction sample and thesecond prediction sample to (7:1) or (1:7).

Alternatively, as shown in the example of FIG. 29(b), prediction samplesof which the sum of the x-axis coordinate and the y-axis coordinate issmaller than the width or the height of the coding block by 1 may bederived by applying the same weighting value to the first predictionsample and the second prediction sample. Prediction samples of which thesum of the x-axis coordinate and the y-axis coordinate is equal to orsmaller than the width or the height of the coding block by 2 may bederived by setting the weighting value ratio applied to the firstprediction sample and the second prediction sample to (7:1) or (1:7).

As another example, the weighting value may be determined consideringthe position of a prediction sample or the shape of a coding block.Equations 7 to 9 show an example of deriving a weighting value when theleft triangular partition type is applied to a coding block. Equation 7shows an example of deriving a weighting value applied to the firstprediction sample when the coding block is a square shape.w1=(x−y+4)/8  [Equation 7]

In Equation 7, x and y denote the position of a prediction sample. Whena coding block is a non-square shape, a weighting value applied to thefirst prediction sample may be derived as shown in Equation 8 or 9.Equation 8 shows a case where the width of a coding block is greaterthan the height, and Equation 9 shows a case where the width of a codingblock is smaller than the height.w1=((x/whRatio)−y+4)/8  [Equation 8]w1=(x−(y*whRatio)+4)/8  [Equation 9]

When the right triangular partition type is applied to a coding block, aweighting value applied to the first prediction sample may be determinedas shown in Equations 10 to 12. Equation 10 shows an example of derivinga weighting value applied to the first prediction sample when the codingblock is a square shape.w1=(CbW−1−x−y)+4)/8  [Equation 10]

In Equation 10, CbW denotes the width of a coding block. When the codingblock is a non-square shape, the weighting value applied to the firstprediction sample may be derived as shown in Equation 11 or Equation 12.Equation 11 shows a case where the width of a coding block is greaterthan the height, and Equation 12 shows a case where the width of acoding block is smaller than the height.w1=((CbH−1−(x/whRatio)−y)+4)/8  [Equation 1]w1=(CbW−1−x(y*whRatio)+4)/8  [Equation 12]

In Equation 11, CbH denotes the height of the coding block.

As shown in the example, among the prediction samples in the boundaryregion, prediction samples included in the first triangular predictionunit are derived by assigning a weighting value larger than that of thesecond prediction sample to the first prediction sample, and predictionsamples included in the second triangular prediction unit are derived byassigning a weighting value larger than that of the first predictionsample to the second prediction sample.

When diagonal partitioning is applied to a coding block, it may be setnot to apply a combined prediction mode combining the intra predictionmode and the merge mode to the coding block.

Intra prediction is for predicting a current block using reconstructedsamples that have been encoded/decoded in the neighborhood of thecurrent block. At this point, samples reconstructed before an in-loopfilter is applied may be used for intra prediction of the current block.

The intra prediction technique includes matrix-based intra prediction,and general intra prediction considering directionality with respect toneighboring reconstructed samples. Information indicating the intraprediction technique of the current block may be signaled through abitstream. The information may be a 1-bit flag. Alternatively, the intraprediction technique of the current block may be determined based on atleast one among the position of the current block, the size of thecurrent block, the shape of the current block, and an intra predictiontechnique of a neighboring block. For example, when the current blockexists across a picture boundary, it may be set not to apply thematrix-based intra prediction intra prediction to the current block.

The matrix-based intra prediction intra prediction is a method ofacquiring a prediction block of the current block by an encoder and adecoder based on a matrix product between a previously stored matrix andreconstructed samples in the neighborhood of the current block.Information for specifying any one among a plurality of previouslystored matrixes may be signaled through a bitstream. The decoder maydetermine a matrix for intra prediction of the current block based onthe information and the size of the current block.

The general intra prediction is a method of acquiring a prediction blockfor the current block based on a non-angular intra prediction mode or anangular intra prediction mode.

A derived residual picture may be derived by subtracting a predictionvideo from an original video. At this point, when the residual video ischanged to the frequency domain, subjective video quality of the videois not significantly lowered although the high-frequency componentsamong the frequency components are removed. Accordingly, when values ofthe high-frequency components are converted to be small or the values ofthe high-frequency components are set to 0, there is an effect ofincreasing the compression efficiency without generating significantvisual distortion. By reflecting this characteristic, the current blockmay be transformed to decompose a residual video into two-dimensionalfrequency components. The transform may be performed using a transformtechnique such as Discrete Cosine Transform (DCT) or Discrete SineTransform (DST).

The two-dimensional video transform may not be performed for some blocksof the residual video. Not performing the two-dimensional videotransform may be referred to as a transform skip. When the transformskip is applied, quantization may be applied to residual coefficientsthat have not been transformed.

After the current block is transformed using DCT or DST, the transformedcurrent block may be transformed again. At this point, the transformbased on DCT or DST may be defined as a first transform, andtransforming again a block to which the first transform is applied maybe defined as a second transform.

The first transform may be performed using any one among a plurality oftransform core candidates. For example, the first transform may beperformed using any one among DCT2, DCT8, or DCT7.

Different transform cores may be used for the horizontal direction andthe vertical direction. Information indicating combination of atransform core of the horizontal direction and a transform core of thevertical direction may be signaled through a bitstream.

Units for performing the first transform and the second transform may bedifferent. For example, the first transform may be performed on an 8×8block, and the second transform may be performed on a subblock of a 4×4size among the transformed 8×8 block. At this point, the transformcoefficients of the residual regions that has not been performed thesecond transform may be set to 0.

Alternatively, the first transform may be performed on a 4×4 block, andthe second transform may be performed on a region of an 8×8 sizeincluding the transformed 4×4 block.

Information indicating whether or not the second transform has beenperformed may be signaled through a bitstream.

Alternatively, whether or not to perform the second transform may bedetermined based on whether the horizontal direction transform core andthe vertical direction transform core are the same. For example, thesecond transform may be performed only when the horizontal directiontransform core and the vertical direction transform core are the same.Alternatively, the second transform may be performed only when thehorizontal direction transform core and the vertical direction transformcore are different from each other.

Alternatively, the second transform may be allowed only when transformof the horizontal direction and transform of the vertical direction usea predefined transform core. For example, when a DCT2 transform core isused for transform of the horizontal direction and transform of thevertical direction, the second transform may be allowed.

Alternatively, whether or not to perform the second transform may bedetermined based on the number of non-zero transform coefficients of thecurrent block. For example, it may be set not to use the secondtransform when the number of non-zero transform coefficients of thecurrent block is smaller than or equal to a threshold value, and it maybe set to use the second transform when the number of non-zero transformcoefficient of the current block is larger than the threshold value. Itmay be set to use the second transform only when the current block isencoded by intra prediction.

The decoder may perform inverse transform of the second transform(second inverse transform) and may perform inverse transform of thefirst transform (first inverse transform) on a result of the secondinverse transform. As a result of performing the second inversetransform and the first inverse transform, residual signals for thecurrent block may be acquired.

When the encoder performs transform and quantization, the decoder mayacquire a residual block through inverse quantization and inversetransform. The decoder may acquire a reconstructed block for the currentblock by adding a prediction block and the residual block.

When a reconstructed block of the current block is acquired, loss ofinformation occurring in the quantization and encoding process may bereduced through in-loop filtering. An in-loop filter may include atleast one among a deblocking filter, a sample adaptive offset filter(SAO), and an adaptive loop filter (ALF).

Applying the embodiments described above focusing on a decoding processor an encoding process to an encoding process or a decoding process isincluded in the scope of the present disclosure. Changing theembodiments described in a predetermined order in an order differentfrom the described order is also included in the scope of the presentdisclosure.

Although the embodiments above have been described based on a series ofsteps or flowcharts, this does not limit the time series order of thepresent disclosure, and may be performed simultaneously or in adifferent order as needed. In addition, each of the components (e.g.,units, modules, etc.) constituting the block diagram in the embodimentsdescribed above may be implemented as a hardware device or software, ora plurality of components may be combined to be implemented as a singlehardware device or software. The embodiments described above may beimplemented in the form of program commands that can be executed throughvarious computer components and recorded in a computer-readablerecording medium. The computer-readable recording medium may includeprogram commands, data files, data structures and the like independentlyor in combination. The computer-readable recording medium includes, forexample, magnetic media such as a hard disk, a floppy disk and amagnetic tape, optical recording media such as a CD-ROM and a DVD,magneto-optical media such as a floptical disk, and hardware devicesspecially configured to store and execute program commands, such as aROM, a RAM, a flash memory and the like. The hardware devices describedabove can be configured to operate using one or more software modules toperform the process of the present disclosure, and vice versa.

The present disclosure can be applied to an electronic device thatencodes and decodes a video.

What is claimed is:
 1. A video decoding method comprising: applyingpartitioning to a coding block, to obtain a first prediction unit and asecond prediction unit, wherein whether or not to apply partitioning tothe coding block is determined based on a size of the coding block;deriving a merge candidate list for the coding block; deriving firstmotion information for the first prediction unit and second motioninformation for the second prediction unit using the merge candidatelist; obtaining a prediction sample in the coding block based on thefirst motion information and the second motion information, wherein thefirst motion information for the first prediction unit is derived from afirst merge candidate in the merge candidate list, and the second motioninformation for the second prediction unit is derived from a secondmerge candidate different from the first merge candidate; and decodingfirst index information for determining a merge candidate of the firstprediction unit and second index information for determining a mergecandidate of the second prediction unit from a bitstream, wherein when avalue of the second index information is equal to or greater than avalue of the first index information, the value of the second indexinformation is obtained by adding 1 to the value of the second indexinformation.
 2. The method according to claim 1, wherein when at leastone among a width and a height of the coding block is greater than athreshold value, partitioning the coding block is not allowed.
 3. Themethod according to claim 1, wherein a maximum number of mergecandidates that the merge candidate list includes is determined based onwhether the first prediction unit and the second prediction unit isobtained by applying partitioning to the coding block.
 4. The methodaccording to claim 1, wherein the first prediction unit is a firsttriangular prediction unit, and the second prediction unit is a secondtriangular prediction unit.
 5. The method according to claim 1, whereinderiving first motion information for the first prediction unit andsecond motion information for the second prediction unit using the mergecandidate list comprises: deriving the first motion information for thefirst triangular prediction unit from the merge candidate determinedbased on the first index information, and deriving the second motioninformation for the second triangular prediction unit from the mergecandidate determined based on the second index information.
 6. A videoencoding method comprising: applying partitioning to a coding block, toobtain a first prediction unit and a second prediction unit, whereinwhether or not to apply partitioning to the coding block is determinedbased on a size of the coding block; deriving a merge candidate list forthe coding block; deriving first motion information for the firstprediction unit and second motion information for the second predictionunit using the merge candidate list; obtaining a prediction sample inthe coding block based on the first motion information and the secondmotion information, wherein the first motion information for the firstprediction unit is derived from a first merge candidate in the mergecandidate list, and the second motion information for the secondprediction unit is derived from a second merge candidate different fromthe first merge candidate; and encoding first index information fordetermining a merge candidate of the first prediction unit and secondindex information for determining a merge candidate of the secondprediction unit, wherein when an index of the merge candidate of thesecond prediction unit is equal to or greater than an index of the mergecandidate of the first prediction unit, the second index information isencoded using a value obtained by subtracting 1 from the index of themerge candidate of the second prediction unit.
 7. The method accordingto claim 6, wherein when at least one among a width and a height of thecoding block is greater than a threshold value, partitioning the codingblock is not allowed.
 8. The method according to claim 6, furthercomprising encoding first index information for specifying the firstmerge candidate and second index information for specifying the secondmerge candidate from a bitstream, wherein when an index of the secondmerge candidate is greater than an index of the first merge candidate,the second index information is encoded using a value obtained bysubtracting 1 from the index of the second merge candidate.
 9. Themethod according to claim 6, wherein a maximum number of mergecandidates that the merge candidate list includes is determined based onwhether the coding block is partitioned into the first prediction unitand the second prediction unit.
 10. The method according to claim 6,wherein the first prediction unit is a first triangular prediction unit,the second prediction unit is a second triangular prediction unit. 11.The method according to claim 6, wherein deriving first motioninformation for the first prediction unit and second motion informationfor the second prediction unit using the merge candidate list comprises:deriving the first motion information for the first triangularprediction unit from a merge candidate determined based on the firstindex information, and deriving the second motion information for thesecond triangular prediction unit from a merge candidate determinedbased on the second index information.
 12. A video decoding apparatuscomprising an inter prediction part configured to apply partitioning toa coding block to obtain a first prediction unit and a second predictionunit, derive a merge candidate list for the coding block, derive firstmotion information for the first prediction unit and second motioninformation for the second prediction unit using the merge candidatelist, and obtain a prediction sample in the coding block based on thefirst motion information and the second motion information, whereinwhether or not to apply partitioning to the coding block is determinedbased on a size of the coding block, the first motion information forthe first prediction unit is derived from a first merge candidate in themerge candidate list, and the second motion information for the secondprediction unit is derived from a second merge candidate different fromthe first merge candidate; the inter prediction part is configured todecode first index information for determining a merge candidate of thefirst prediction unit and second index information for determining amerge candidate of the second prediction unit from a bitstream; and whena value of the second index information is equal to or greater than avalue of the first index information, the value of the second indexinformation is obtained by adding 1 to the value of the second indexinformation.
 13. The video decoding apparatus according to claim 12,wherein when at least one among a width and a height of the coding blockis greater than a threshold value, partitioning the coding block is notallowed.
 14. The video decoding apparatus according to claim 12, whereina maximum number of merge candidates that the merge candidate listincludes is determined based on whether the coding block is partitionedinto the first prediction unit and the second prediction unit.
 15. Thevideo decoding apparatus according to claim 12, wherein the firstprediction unit is a first triangular prediction unit, and the secondprediction unit is a second triangular prediction unit.
 16. A videoencoding apparatus, comprising: an inter prediction part, configured toapply partitioning to a coding block, to obtain a first prediction unitand a second prediction unit, wherein whether or not to applypartitioning to the coding block is determined based on a size of thecoding block; and derive a merge candidate list for the coding block,derive first motion information for the first prediction unit and secondmotion information for the second prediction unit using the mergecandidate list, and obtain a prediction sample in the coding block basedon the first motion information and the second motion information,wherein the first motion information for the first prediction unit isderived from a first merge candidate in the merge candidate list, andthe second motion information for the second prediction unit is derivedfrom a second merge candidate different from the first merge candidate;and decode first index information for determining a merge candidate ofthe first prediction unit and second index information for determining amerge candidate of the second prediction unit from a bitstream, whereinwhen a value of the second index information is equal to or greater thana value of the first index information, the value of the second indexinformation is obtained by adding 1 to the value of the second indexinformation.
 17. The video encoding apparatus according to claim 16,wherein when at least one among a width and a height of the coding blockis greater than a threshold value, partitioning the coding block is notallowed.
 18. The video encoding apparatus according to claim 16, whereina maximum number of merge candidates that the merge candidate listincludes is determined based on whether the coding block is partitionedinto the first prediction unit and the second prediction unit.